R
R
Rodion Yurchenko2020-06-29 17:29:28
Python
Rodion Yurchenko, 2020-06-29 17:29:28

How to upload a picture to instagram using windows+python+selenium?

Good afternoon!
In short, I'm trying to make a post with a picture on instagram on a bunch of windows + selenium + python. I
stumbled at the moment when a window pops up to select a picture on a local disk

. Google offers something like the following options
1 - find the type field <input type="file">and send the path to the downloaded file there via sendKeys , and submit the form
2 - modify the html and add the form itself to submit the image and submit it yourself...
3 - use pyautogui and interact with the windows loading window

I failed with all 3 methods
1st method requires the presence of such a field - I could not find it is in the source code of the page, apparently everything is intercepted by javascript and everything itself is fart
2nd method - if you look at what Instagram sends when uploading an image - there is still a huge cloud of data, in addition to the file itself, it is sent - tried to send a POST request with approximately the same data - it didn’t work, you need an exact data set
Here is an example of what Instagram sends during a normal file upload

access_token: 1217981644879628|65a937f07619e8d4dce23
message: {"app_uid":"33053346601","app_id":"1217981644879628","app_ver":"1.0.0","data":[{"time":1593439568.264,"name":"instagram_web_time_spent_bit_array","extra":{"ig_userid":33053346601,"pk":33053346601,"rollout_hash":"4f336da7de59","frontend_env":"prod","qe":{"felix_clear_fb_cookie":"control"},"app_id":"1217981644879628","tos_id":"ggll36","start_time":1593439567,"tos_array":[3,0],"tos_len":2,"tos_seq":58,"tos_cum":146,"log_time":1593439568264,"referrer":"https://www.instagram.com/","referrer_domain":"www.instagram.com","url":"/","original_referrer":"","original_referrer_domain":""}},{"time":1593439568.314,"name":"instagram_web_client_events","extra":{"event_type":"action","event_name":"cameraIconClick","mid":"XvnjAAABAAGxLsqdwcElewYTZ7mf","ig_userid":33053346601,"pk":33053346601,"rollout_hash":"4f336da7de59","frontend_env":"prod","qe":{"felix_clear_fb_cookie":"control"},"app_id":"1217981644879628","referrer":"https://www.instagram.com/","referrer_domain":"www.instagram.com","original_referrer":"","original_referrer_domain":""},"module":null,"obj_type":"url","obj_id":"/"},{"time":1593439568.317,"name":"instagram_web_creation","extra":{"ig_userid":33053346601,"pk":33053346601,"rollout_hash":"4f336da7de59","frontend_env":"prod","qe":{"felix_clear_fb_cookie":"control"},"app_id":"1217981644879628","event_name":"enter_flow","creation_session_id":"bhbhaymujbl","stage":"camera_entry_page","entry_ref":"camera_icon","gl_supported":true,"gl_renderer":"ANGLE (NVIDIA GeForce GTX 1060 6GB Direct3D11 vs_5_0 ps_5_0)","referrer":"https://www.instagram.com/","referrer_domain":"www.instagram.com","url":"/","original_referrer":"","original_referrer_domain":""}}],"log_type":"client_event","seq":3,"session_id":"17300660254-f83fa3","device_id":"870B514C-EC1F-4695-B011-919D85B14C78","claims":["hmac.AR1O1_jrBcY1WMWiG54J6RTQAL-Q92OfdWYJZ2StEMrccxn0"]}

3 using pyautogui is also not so simple - as I understand it - pyautogui cannot understand which window is currently active, and cannot change focus - and without this, it remains only to blindly search for the field by coordinates and click in the hope that it hit the right place - in in general, there is little hope either.

I understand that asking for a ready-made code is too brazen, but could you comment on my problem and give advice on how to solve the problem or in which direction you can still dig

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2020-06-29
@dimonchik2013

https://www.guru99.com/upload-download-file-seleni...
can you handle it further?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question