【问题标题】:UnicodeEncodeError: 'latin-1' codec can't encode character '\u201d' in position 0: ordinal not in range(256)UnicodeEncodeError:“latin-1”编解码器无法在位置 0 编码字符“\u201d”:序数不在范围内(256)
【发布时间】:2021-04-24 03:25:56
【问题描述】:

如果有人知道帮助我,我对 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)

【问题讨论】:

    标签: python python-requests instagram


    【解决方案1】:

    sec-ch-ua 标头的值以一个奇怪的字符开头。将其替换为"

    【讨论】:

      猜你喜欢
      • 2016-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-13
      • 2011-04-25
      • 2014-01-22
      相关资源
      最近更新 更多