【发布时间】:2023-01-17 05:29:03
【问题描述】:
我试图用 scrapy 抓取以下 url,但它返回 301 状态。虽然简单的 python requests 工作得很好。
网址 = https://www.depop.com/products/saltybrasi-perte-dego-white-lace-shirt/
我在具有默认设置的任何项目之外的Scrapy Shell 中运行测试。
>>> import requests
>>> r = requests.get('https://www.depop.com/products/saltybrasi-perte-dego-white-lace-shirt/')
2023-01-16 17:01:16 [urllib3.connectionpool] DEBUG: Starting new HTTPS connection (1): www.depop.com:443
2023-01-16 17:01:17 [urllib3.connectionpool] DEBUG: https://www.depop.com:443 "GET /products/saltybrasi-perte-dego-white-lace-shirt/ HTTP/1.1" 200 None
>>> fetch('https://www.depop.com/products/saltybrasi-perte-dego-white-lace-shirt/')
2023-01-16 17:01:31 [scrapy.core.engine] INFO: Spider opened
2023-01-16 17:01:31 [scrapy.core.engine] DEBUG: Crawled (301) <GET https://www.depop.com/products/saltybrasi-perte-dego-white-lace-shirt/> (referer: None)
>>>
两者之间有什么区别,我如何使它与 Scrapy 一起工作? 谢谢。
【问题讨论】:
-
可能是因为 scrapy 的默认用户代理。
标签: python-3.x python-requests scrapy