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. javascript - 关于jsp中嵌入js代码的问题2. javascript - 百度坐标,返回目标附近有哪些坐标3. PHP类中的$this4. javascript - html5多个label中其中一个触发change,如何判断是哪一个出发了change5. angular.js - angurlarJS的安卓的微信端中用加载ngCookies会出错的问题6. clone - git sourceTree克隆仓库时,都不停弹出Password Required弹窗,即时输入正确的git账号密码还是弹出7. python - 怎么通过vpn连内网ftp?8. javascript - 一个JS多元运算符的问题9. javascript - 关于fullpage.js的横向滚动控制10. python 正则表达式提取

网公网安备