我正在使用Scrapy
进行网页抓取,成功创建了一个蜘蛛,它将抓取整个网站,包括具有相同域的内部链接,我使用了链接提取器来实现这一点。这种抓取在英语网站上很成功,但当我尝试抓取德语网站时,它不起作用,回调function parse_item()
不会被调用。如果我将parse_item()
更改为parse()
,则会删除德国网站域URL,但不会删除内部链接。我该如何解决这个问题
下面是我的代码:
class WebSpider(CrawlSpider):
name = 'WebSpider'
#init function
def __init__(self, *args, **kwargs):
#code to accept domain url
WebSpider.rules = [
Rule(LinkExtractor(unique=True), callback='parse_item', follow=True)
]
super(WebSpider, self).__init__(*args, **kwargs
def parse_item(self, response):
#Call back function to work with response
目前没有回答
相关问题 更多 >
编程相关推荐