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. mysql - 在不允许改动数据表的情况下,如何优化以varchar格式存储的时间的比较?2. css - chrome下a标签嵌套img 显示会多个小箭头?3. javascript - 网页打印页另存为pdf的代码一个问题4. vim - docker中新的ubuntu12.04镜像,运行vi提示,找不到命名.5. java中返回一个对象,和输出对像的值,意义在哪儿6. css3 - 纯css实现点击特效7. docker网络端口映射,没有方便点的操作方法么?8. mysql 为什么主键 id 和 pid 都市索引, id > 10 走索引 time > 10 不走索引?9. javascript - Img.complete和img.onload判断图片加载完成有什么区别?10. javascript - 有适合开发手机端Html5网页小游戏的前端框架吗?
