2024-03-29 13:30:00 发布
网友
我看到了this帖子,让scrapy抓取任何不受域限制的站点。
有没有更好的方法可以做到这一点,比如在allowed domains变量中使用正则表达式,比如-
allowed_domains = ["*"]
我希望有其他的方法,而不是侵入到scrapy框架来做这件事。
你应该激活离线的middlware,这是一个在scrapy中内置的蜘蛛中间件。 有关详细信息http://doc.scrapy.org/en/latest/topics/spider-middleware.html
根本不设置允许的域。
看看这个垃圾文件中的get_host_regex()函数:
https://github.com/scrapy/scrapy/blob/master/scrapy/contrib/spidermiddleware/offsite.py
你应该激活离线的middlware,这是一个在scrapy中内置的蜘蛛中间件。 有关详细信息http://doc.scrapy.org/en/latest/topics/spider-middleware.html
根本不设置允许的域。
看看这个垃圾文件中的get_host_regex()函数:
https://github.com/scrapy/scrapy/blob/master/scrapy/contrib/spidermiddleware/offsite.py
相关问题 更多 >
编程相关推荐