简体   繁体   English

Python requests.post 不发布(绕过 cloudfare)

[英]Python requests.post doesn't post (with cloudfare bypass)

I created a skript that will create and account on: https://stress95.com/en/auth/view?op=register我创建了一个脚本,将在以下位置创建和帐户: https ://stress95.com/en/auth/view?op=register

import requests
import cloudscraper
import time


url = ('https://stress95.com/en/auth/view?op=register')

headers = {

    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36'
}


payload = {'firstName': 'test', 'email': 'afaff@pytronik.club', 'password': '12341fbb14', 'action': 'register', '_AntiCsrfToken': '3dee97c161c84c13a4400d19a8c6565c'}

scraper = cloudscraper.create_scraper(interpreter='nodejs')  # returns a CloudScraper instance
# Or: scraper = cloudscraper.CloudScraper()  # CloudScraper inherits from requests.Session
#print(scraper.get(url).text)

r = scraper.post(url, data=payload, headers=headers)
print(r.text)

Please help me out I'm getting crazy about this请帮帮我,我对此很着迷

This is because you are posting to the wrong place .这是因为您发布到错误的地方 The url you linked is the endpoint that has a registration form.您链接的 url 是具有注册表单的端点。 That registration form posts over here:那个登记表张贴在这里:

<form action="/en/auth/submit" method="post" class="login-form">
...
</form>

It's also worth nothing that just posting to their page isn't likely to do much because the first element in their form as an anti-csrf token:仅仅发布到他们的页面不太可能做太多事情也没有任何价值,因为他们表单中的第一个元素作为反 csrf 令牌:

<input type="hidden" name="_AntiCsrfToken" value="149d3fbcfdf74aec9eed68a4b78d33bf">

Your post won't have that value unless you loaded it from the page, which means they'll just reject your request.除非您从页面加载它,否则您的帖子不会具有该价值,这意味着他们只会拒绝您的请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM