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. 编辑成功不显示弹窗2. 哭辽 求大佬解答 控制器的join方法怎么转模型方法3. Navicat for mysql 中以json格式储存的数据存在大量反斜杠,如何去除?4. mysql - 数据库表中,两个表互为外键参考如何解决5. mysql储存json错误6. mysql - 怎么生成这个sql表?7. mysql - 表名称前缀到底有啥用?8. sql语句 - 如何在mysql中批量添加用户?9. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE语法实现存在即更新应该使用哪个标签?10. 怎么php怎么通过数组显示sql查询结果呢,查询结果有多条,如图。
