CloudFlare scrape不会检索所有cookie

时间:2018-10-19 23:53:38

标签: python-3.x web-scraping request python-requests cloudflare

我正在尝试在cloudflare设置的网站上执行POST请求。为了执行此网站上的POST请求,我需要cookie,但是使用cfscrape我只能检索3个必要cookie中的2个(缺少_hs_session_v3 cookie)。这是我的代码:

import cfscrape
scrape = cfscrape.create_scraper()
payload = {"variant_id": "107917", "quantity": "1"}
tokens, user_agent=scrape.get_tokens("https://www.off---white.com/en/IT/women/products/owea143e18a640731001")
headers={
    "authority":"www.off---white.com",
    "accept":"application/json, text/javascript, */*; q=0.01",
    "accept-encoding": "gzip, deflate, br",
    "accept-language": "en-US,en;q=0.9",
    "content-length": "35",
    "content-type": "application/json; charset=UTF-8",
    "refer": "https://www.off---white.com/en/IT/women/products/owea143e18a640731001",
    "origin":"https://www.off---white.com",
    "user-agent": user_agent,
    "x-requested-with": "XMLHttpRequest"
        }
res = scrape.post("https://www.off---white.com/en/IT/orders/populate.json",headers=headers,data=payload,cookies=tokens)
print(res.status_code) #=403forbidden because invalid request

0 个答案:

没有答案