我正在写破烂的代码爬行的第一页和一个额外的深度给定的网页
不知怎么的,我的爬虫没有进入额外的深度。只是抓取给定的起始URL并结束其操作。在
我甚至连获取链接的规则都被忽略了。什么是可能的原因,我能改变什么使它遵循规则
import scrapy
from scrapy.contrib.spiders import CrawlSpider, Rule
from crawlWeb.items import CrawlwebItem
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
class DmozSpider(CrawlSpider):
name = "premraj"
start_urls = [
"http://www.broadcom.com",
"http://www.qualcomm.com"
]
rules = [Rule(SgmlLinkExtractor(), callback='parse',process_links="process_links",follow=True)]
def parse(self, response):
#print dir(response)
#print dir(response)
item=CrawlwebItem()
item["html"]=response.body
item["url"]=response.url
yield item
def process_links(self,links):
print links
print "hey!!!!!!!!!!!!!!!!!!!!!"
在CrawlSpider documentation中有一个警告框。上面写着:
您的代码可能无法按预期工作,因为您确实使用了
parse
作为回调函数。在相关问题 更多 >
编程相关推荐