我在使用代码:
def parse_find(self, response):
Download_URL = "https://download.example.com/b/zMTY"
request = Request(Download_URL, callback=self.parse_final)
yield request
def parse_final(self, response):
redirected_URL = response.url
FileName = response.headers['Content-Disposition']
yield{ "Download_URL":redirected_URL,
"FileName":FileName}
获取重定向的url及其标头,但scrapy提供了调试:
2018-07-30 04:41:49 [scrapy.downloadermiddlewares.redirect] DEBUG: Redirecting (
302) to <GET https://example.com/url> from <GET https://download.example.com/b/zMTY>
2018-07-30 04:41:51 [scrapy.downloadermiddlewares.redirect] DEBUG: Redirecting (
meta refresh) to <GET https://example.com> from <GET https://example.com/url>
必须注意的是,当我在scrapyshell中使用fetch提取这个url时,它会获取重定向的url并响应.标题很好用。你知道吗
我使用的是python3.6.5和scrapy1.5
由于我无法使用scrapy,我已通过以下请求完成:
这不是一个错误-这是一个
debug
日志。Scrapy通知您重定向是为了调试目的而发生的。您可以使用LOG_LEVEL
设置更改残片日志级别。在dev环境之外,应该将其设置为LOG_LEVEL = 'INFO'
相关问题 更多 >
编程相关推荐