[英]Scrapy request, shell Fetch() in spider
I'm trying to reach a specific page, let's call it http://example.com/puppers
. 我正在尝试访问特定页面,我们称其为
http://example.com/puppers
。 This page cannot be reached when connecting directly using scrapy shell
or the standard scrapy.request
module (results in <405> HTTP
). 当直接使用
scrapy shell
或标准scrapy.request
模块(结果为<405> HTTP
)连接时,无法访问此页面。
However, when I use scrapy shell 'http://example.com/kittens'
first, and then use fetch('http://example.com/puppers')
it works and I get a <200> OK HTTP
code. 但是,当我先使用
scrapy shell 'http://example.com/kittens'
,然后使用fetch('http://example.com/puppers')
它可以工作,并且我得到<200> OK HTTP
代码。 I can now extract data using scrapy shell
. 我现在可以使用
scrapy shell
提取数据。
I tried implementing this in my script, by altering the referer
(using url #1), the user-agent
and a few others while connecting to the puppers (url #2) page. 我试着在我的脚本实现这一点,通过改变
referer
(使用URL#1),在user-agent
和其他几个人同时连接到puppers(URL#2)页面。 I still get a <405> code.. 我仍然收到<405>代码。
I appreciate all the help. 我感谢所有的帮助。 Thank you.
谢谢。
start_urls = ['http://example.com/kittens']
def parse(self, response):
yield scrapy.Request(
url="http://example.com/puppers",
callback=self.parse_puppers
)
def parse_puppers(self, response):
#process your puppers
.....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.