Description
I want upload userpic in social network (vk.com) automaticly.
In the browser code inspector upload block looks like this:
<div class="inline_upload_wrap pointer_wrap _touched">
<input
type="file"
class="inline_upload"
onchange="return ownerPhotoUpload.start(this, event);"
accept="image/*"
data-upload-url="https://pu.vk.com/c633130/upload.php?act=owner_photo&oid=-115785066&square=&_fwadd=-115785066&mid=248870261&server=633130&_origin=https%3A%2F%2Fm.vk.com&_sig=a583bf541a5ebc8676830fca26b049ca"
data-base-url="https://pu.vk.com/c633130/"
data-static-url="https://pp.vk.me/c633130/">
<a href="/album-115785066_0?act=add&from=profile" class="pm_item profile_photo_upload_wrap"></a>
</div>
What I tried
input_elem.send_keys(path)
doesn't do anything.- send binary file by
request.post
with cookies from selenium driver and with url that contains in<input data-upload-url="URL">
. Response is a string: "security breach"
Why it doesn't work
input
has a field onchange="return ownerPhotoUpload.start(this, event);"
This function:
start: function(e, t) {
if (!e || !canUploadFile()) return ownerPhotoUpload.fallback(e, t);
var a = e.files,
n = a[0] || !1,
o = attr(e, "data-upload-url"),
i = attr(e, "data-base-url"),
r = attr(e, "data-static-url");
if (!n) return !1;
if (!o) return ownerPhotoUpload.fallback(e, t);
var s = {
upload_url: o,
base_url: i,
static_url: r,
file: n
};
return s.xhr = uploadFile(o, {
photo: n
}, {
onProgress: bind(ownerPhotoUpload.onUploadProgress, s),
onComplete: bind(ownerPhotoUpload.onUploadComplete, s),
onError: bind(ownerPhotoUpload.onUploadError, s)
}), readFile(n, function(e) {
photoview.updateUpload({
thumb: e
})
}), replace(clone(e), e), photoview.onClose = bind(ownerPhotoUpload.onClose, s), photoview.openUpload({
src: null
}), !1
},
It has the same things as href in input. So, I think, that I just have to add or change some data in my request.
What can I do?
- add some data to request (what data?)
- do send_keys in other way (what way?)
- handle a window for picking an image that appers when I click button "Upload a picture" (how to handle it in linux?)