【问题标题】:Retrieving crawled urls Scrapy检索抓取的网址 Scrapy
【发布时间】:2014-04-04 23:40:13
【问题描述】:

我已经构建了一个爬虫来使用 Scrapy 爬取特定网站。如果 url 与给定的正则表达式匹配,则爬虫会跟随,如果 url 与其他定义的正则表达式匹配,则调用回调函数。构建爬虫的主要目的是提取网站内所有需要的链接,而不是链接内的内容。谁能告诉我如何打印所有已抓取链接的列表。代码是:

name = "xyz"
allowed_domains = ["xyz.com"]
start_urls = ["http://www.xyz.com/Vacanciess"] 
rules = (Rule(SgmlLinkExtractor(allow=[regex2]),callback='parse_item'),Rule(SgmlLinkExtractor(allow=[regex1]), follow=True),)



def parse_item(self, response):
 #sel = Selector(response)

 #title = sel.xpath("//h1[@class='no-bd']/text()").extract()
 #print title
 print response

print title 

代码运行良好。但是就像上面的代码一样,如果我尝试打印实际的响应,它会返回给我:

[xyz] DEBUG: Crawled (200)<GET http://www.xyz.com/urlmatchingregex2> (referer:  http://www.xyz.com/urlmatchingregex1)
<200 http://www.xyz.com/urlmatchingregex2>

请任何人帮助我检索实际的网址。

【问题讨论】:

    标签: python scrapy web-crawler


    【解决方案1】:

    您可以在parse_item方法中打印response.url来打印抓取到的url。它记录在here

    【讨论】:

      猜你喜欢
      • 2018-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多