简体   繁体   English

Scrapy.Request()在parse方法中不起作用

[英]Scrapy.Request() doesn't work in parse method

I have an issue the following code in my Spider-Class: 我在Spider-Class中遇到以下代码问题:

  def parse(self, response):
        item = ResponseItem();
        item['url'] = response.headers["Location"]
        item['status'] = response.status


        filename = response.url.split("/")[-2] + '.txt'
        with open (filename, 'wb') as f:
            f.write("%r" %response.status)
            f.write("\r\n")
            f.write("%s" %item['url'])

        return scrapy.Request("http://www.google.com/", callback=self.testparse)

def testparse(self, response): ...

Scrapy/Python doesn't do the Request defined in the parse-Method. Scrapy / Python不执行parse-Method中定义的Request。 I'm quite new to Scrapy and Python, so can anyone tell me, what I've made wrong? 我对Scrapy和Python很陌生,所以有人能告诉我,我做错了吗?

(The request-URL is just an example) (请求URL只是一个例子)

Sorry for my late response, but I have found my solution. 很抱歉我迟到了,但我找到了解决办法。 Idiotically I forgot to set the right allowed domains... 我忘了设置正确允许的域名...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM