绕过403响应的可能方法

问题描述 投票:0回答:1

我正在尝试从具有运动鞋销售历史数据的Stockx表中抓取数据。当我创建一个python shell并检查响应时,我收到此消息:<403 https://stockx.com/adidas-yeezy-boost-350-v2-steeple-grey-beluga-solar-red>。无论如何,都可以绕过403来提取数据,还是应该寻找另一种收集数据的方法?也许API?

python scrapy anaconda http-status-code-403
1个回答
0
投票

设置正确的标题似乎可以解决此问题。您可以使用scrapy shell测试以下内容:

url = "https://stockx.com/adidas-yeezy-boost-350-v2-steeple-grey-beluga-solar-red"
headers = {
     'authority': 'stockx.com',
     'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36',
     'sec-fetch-dest': 'document',
     'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
     'sec-fetch-site': 'none',
     'sec-fetch-mode': 'navigate',
     'accept-language': 'en-GB,en;q=0.9,nl-BE;q=0.8,nl;q=0.7,ro-RO;q=0.6,ro;q=0.5,en-US;q=0.4,fr;q=0.3,it;q=0.2',
}
from scrapy import Request
req = Request(url, headers=headers)
fetch(req)
© www.soinside.com 2019 - 2024. All rights reserved.