抓取网站时获取 404 错误页面的问题

时间:2021-05-16 13:01:58

标签: python web-crawler

我想从“https://alternative.me/crypto/”获取恐惧和贪婪索引,我通过使用 Chrome 网络工具找到了 XHR 数据所在的网址,但在尝试抓取时网站,我收到了 404 或 500 错误页面。

url = 'https://alternative.me/api/crypto/fear-and-greed-index/history'
headers = {
    'user-agent': ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36'),
    'Referer': ('https://alternative.me/crypto/fear-and-greed-index/'),
    'Accept-Language': ('ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7'),
    'accept-encoding': ('gzip, deflate, br'),
    'accept': ('application/json, text/plain, */*')
}

res = requests.post(url, headers=headers)

0 个答案:

没有答案