错误 401 发送带有请求的 recaptcha 令牌 [英] Error 401 sending recaptcha token with requests
问题描述
我尝试为此网站制作购物车:https://www.off---white.com/en/IT
I tried to make a cart for this site: https://www.off---white.com/en/IT
当我尝试发送购物车参数的值时,其中一个参数是 recaptcha 的标记.我尝试使用这个项目手动获取令牌'https://github.com/Cosmo3904/Recaptcha-Harvester-V2'
When I tried to send values for the params of the cart, one of this params is a token of recaptcha. I tried manually to get the token using this project 'https://github.com/Cosmo3904/Recaptcha-Harvester-V2'
当我尝试提出请求时,我传递了所有参数:
When I tried to make the request I pass all params:
token = 'recaptcha_token' #(I get it manually and expires every 110s)
payload = {"variant_id": "111380", "quantity": "1", 'g-recaptcha-response': token}
s = requests.Session()
resp2 = s.post("https://www.off---white.com/en/IT/orders/populate.json",headers=headers,data=payload)
print('STATUS CODE: ' + str(resp2.status_code))
不幸的是,每次响应都是 401,这意味着未经授权.我该如何解决这个问题?
unfortunately the response is every time 401, that means unauthorised. How can I solve this?
(对于会话,我传递标头和 cookie 以便正确配置页面,我在尝试登录之前检查了它并且可以正常工作)
(To the session I pass headers and cookies so the page is right configured, I checked before trying login and it works)
推荐答案
import cfscrape
s = requests.Session()
scraper = cfscrape.create_scraper(s)
scraper.get('https://www.off---white.com/en/IT', headers=headers)
url = 'https://www.off---white.com/en/IT/orders/populate.json'
r = scraper.post(url, data={'variant_id' : 'variant', 'quantity' : 1, 'g-recaptcha-response': token}, headers=headers)
尝试使用 cfscrape.
Try with cfscrape.
这篇关于错误 401 发送带有请求的 recaptcha 令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!