错误401发送带有请求的Recaptcha令牌

时间:2018-11-28 09:57:59

标签: json python-3.x python-requests recaptcha invisible-recaptcha

我试图为该网站制作购物车:https://www.off---white.com/en/IT

当我尝试发送购物车参数的值时,其中一个参数是recapcha的标记。我尝试使用此项目'https://github.com/Cosmo3904/Recaptcha-Harvester-V2'

手动获取令牌

当我尝试发出请求时,我传递了所有参数:

    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,这意味着未经授权。我该怎么解决?

(在会话中,我传递了标题和cookie,因此该页面已正确配置,我在尝试登录之前进行了检查,它可以正常工作)

1 个答案:

答案 0 :(得分:0)

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。