python - UnicodeEncodeError:“latin-1”编解码器无法在位置 0 编码字符“\u201d”:序数不在范围内(256)
问题描述
如果有人知道帮助我,我对 Instagram 上的请求有疑问。
这是代码:
import requests
username = input('user: ')
headers = {
'accept':'*/*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-ZW,en-US;q=0.9,en;q=0.8',
'content-length': '84',
'content-type': 'application/x-www-form-urlencoded',
'cookie': 'ig_cb=2; ig_did=9A4D7DF8-A4A7-4061-A279-9B69C4683ED2; mid=YED50AAEAAGr9ZEXMr25akKRsufT; shbid=14062; rur=ATN; shbts=1619229397.0332613; csrftoken=Pa0VXyUGq674IOlySdbKFFLSGmhHWXQu',
'origin': 'https://www.instagram.com',
'referer':'https://www.instagram.com/accounts/password/reset/',
'sec-ch-ua': '”Google Chrome";v="89", "Chromium";v="89", ";Not\"A\\Brand";v="99”',
'sec-ch-ua-mobile': '?1',
'sec-fetch-dest':'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Mobile Safari/537.36',
'x-csrftoken': 'Pa0VXyUGq674IOlySdbKFFLSGmhHWXQu',
'x-ig-app-id': '1217981644879628',
'x-ig-www-claim': 'hmac.AR1kp8P0iLWIGnK2piGMehJw2lZQaN68UqFoWWr4QtEB0gPY',
'x-instagram-ajax': '822bad258fea',
'x-requested-with': 'XMLHttpRequest'
}
data = {
'email_or_username': username
}
req = requests.post('https://www.instagram.com/accounts/account_recovery_send_ajax/', headers=headers , data=data).text
print(req)
解决方案
sec-ch-ua
标题的值以一个奇怪的字符开头。将其替换为"
。
推荐阅读
- react-native - 使用 React Native 和 Expo 进行 MIDI 通信
- ubuntu - Ubuntu 上的 Tomcat SSL 配置
- python - ValueError: no enough values to unpack (expected 2, got 1) 使我无法完成我的代码
- python - Pip 在 Artifactory 中找不到 PyPI 包
- fortran - 在fortran中使用MPI_PUT,不同等级使用c_loc有不同的位移
- django - python_ldap | 在变量中提供证书内容
- java - 如何从Android中的自定义位置编号加载webView
- java - 在 Java 8 计算其值后返回映射键的方法
- javascript - ag-grid CellEditor 单元格高度不正确
- html - IE 中的 HTML CSS 渲染问题