【发布时间】:2019-04-29 07:02:09
【问题描述】:
我正在尝试使用 python 发布请求更改我的 Instagram 个人资料图片,但它没有改变。我没有收到任何错误,在回复中,它说他们改变了它,但改成了白色的 Instagram 人物照片,而不是我选择的照片。
request url: https://www.instagram.com/accounts/web_change_profile_picture/
request headers: :authority: www.instagram.com
:method: POST
:path: /accounts/web_change_profile_picture/
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7
content-length: 251409
content-type: multipart/form-data; boundary=----WebKitFormBoundarySbMgVbqkrGZYUfnE
cookie: ig_cb=1; mid={mid}; mcd=3; rur=ATN; ig_gdpr_signup=1; csrftoken={my_csrf}; shbid=9320; shbts=1543326033.1119306; ds_user_id={my_userid}; sessionid=3215216108%3A3qIcf1SYxlvIOd%3A29; urlgen="{my_urlgen}:7zHjeu:bVP01Os-2jGH6RETg-jCpkDsaRf"
origin: https://www.instagram.com
referer: https://www.instagram.com/{username}/
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
x-csrftoken: {my_csrf}
x-instagram-ajax: {my_ajax}
x-requested-with: XMLHttpRequest
Form data:
profile_pic: (binary)
View Source form data:
------WebKitFormBoundarySbMgVbqkrGZYUfnE
Content-Disposition: form-data; name="profile_pic"; filename="profilepic.jpg"
Content-Type: image/png
------WebKitFormBoundarySbMgVbqkrGZYUfnE--
My code:
s.headers.update(headers_above)
img_payload = {
"file": ("blo.jpg", open("D:\\{path_to_jpg_file}", "rb"), "image/jpeg")
}
img_url = "https://www.instagram.com/accounts/web_change_profile_picture/"
r3 = s.post(img_url, files=img_payload)
【问题讨论】:
-
检查填充物是否没有被缓存。
-
我该怎么做?
-
@PedroLobito 如果您指的是图像的路径,那么它可以正常工作,我已经使用 PIL Image 模块进行了检查。我认为是请求有问题,问题是我不知道问题是什么,哈哈。
-
我会用我的试试,然后告诉你结果。
-
"我该怎么做?" - 在 FF 上,按住 Shift 键并左键单击重新加载按钮
标签: python post request python-requests instagram