POST请求运行没有错误,但没有执行应做的操作

时间:2018-12-04 18:08:44

标签: python beautifulsoup python-requests

所以我在处理请求时遇到了一些麻烦,我不知道为什么会这样。我之前意识到这一点,但我认为这是我自己的事情(可能仍然是,但我不知道它是什么,因此是问题)。我正在为Instagram编写脚本。我可以创建Instagram帐户了。但是我希望它跟随我想要的人。这是我使用的代码:

    pat = '/web/friendships/' + e + '/follow/'
headers = {
    'authority': 'www.instagram.com',
    'method': 'POST',
    'path': pat,
    'scheme': 'https',
    'accept': '*/*',
    'accept-encoding': 'gzip, deflate, br',
    'accept-language': 'en-US,en;q=0.9,es;q=0.8,zh-CN;q=0.7,zh;q=0.6',
    'content-length': '0',
    'origin': 'https://www.instagram.com',
    'referer': link,
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36',
    'x-csrftoken': 'eARRsWAqOvY73Xi9Fe3WLrWK9Rdxjy6o',
    'x-instagram-ajax': 'a6abd1200036',
    'x-requested-with': 'XMLHttpRequest'
}


link = 'https://www.instagram.com/web/friendships/' + e + '/follow/'
w = s.post(link, headers = headers,proxies = proxies)

print(Fore.YELLOW + time.strftime("[%Y-%m-%d %H:%M:%S]") + Fore.GREEN + 'Followed ' + e)

因此,此请求运行无任何错误。我已经在脚本的开头设置了s = requests.Session()。 AFAIK会完全像您在Instagram上一样复制POST请求。那为什么这不起作用呢?脚本运行时没有错误。

此问题的另一个示例是在我正在处理的Slickdeals脚本中。我已登录该帐户才能正常工作,但是当我转到清单并尝试使用请求进行投票时,会发生相同的事情(脚本中没有错误,但未投票通过)。我使用的代码是这样的:

cool = {
'authority': 'slickdeals.net',
'method': 'POST',
'path': '/forums/sdthreadrate_ajax.php',
'scheme': 'https',
'accept': '*/*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en,en-US;q=0.9',
'origin': 'https://slickdeals.net',
'referer': link,
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36',
'x-requested-with': 'XMLHttpRequest',
 }
vote_up_payload = {
   'ajax': '1',
   'do': 'sdthreadratevote',
   'postid': postid,
   'vote': '1',
   'votetypeid': '1',
   'controltype': 'modern',
   'securitytoken': sec_token,
   'where_from': '/forums/sdthreadrate_ajax.php',
}
voteu = s.post('https://slickdeals.net/forums/sdthreadrate_ajax.php', 
headers = cool, data = vote_up_payload)
print('done')

那是什么问题?为什么该脚本可以工作,但不能正常工作?

[编辑]:好的instagram问题是有道理的。关于滑动处理无效的任何原因?

0 个答案:

没有答案