python - scrapy爬虫不能循环运行?
问题描述
scrapy只能爬取一个页面上的链接,不能持续运行爬完全站,以下是代码,初学求指导。
class DbbookSpider(scrapy.Spider): name = 'imufe' allowed_domains = [’http://www.imufe.edu.cn/’] start_urls=(’http://www.imufe.edu.cn/main/dtxw/201704/t20170414_127035.html’) def parse(self, response):item = DoubanbookItem()selector = scrapy.Selector(response)print(selector)books = selector.xpath(’//a/@href’).extract()link=[]for each in books: each=urljoin(response.url,each) link.append(each)for each in link: item[’link’] = each yield itemi = random.randint(0,len(link)-1)nextPage = link[i]yield scrapy.http.Request(nextPage,callback=self.parse)
问题解答
回答1:是不是爬得太快让封了
相关文章:
1. debian - docker依赖的aufs-tools源码哪里可以找到啊?2. 为什么我ping不通我的docker容器呢???3. 对html实现监测 发现不对4. dockerfile - 为什么docker容器启动不了?5. docker内创建jenkins访问另一个容器下的服务器问题6. angular.js - angular内容过长展开收起效果7. docker - 各位电脑上有多少个容器啊?容器一多,自己都搞混了,咋办呢?8. javascript - js中向下取整9. 在mac下出现了两个docker环境10. angular.js使用$resource服务把数据存入mongodb的问题。

网公网安备