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. 微信开放平台 - Android调用微信分享不显示2. javascript - ie11以下单击打开不了file,双击可以。求解?3. javascript - js 有什么优雅的办法实现在同时打开的两个标签页间相互通信?4. javascript - 关于定时器 与 防止连续点击 问题5. objective-c - ios百度地图定位问题6. javascript - 求助这种功能有什么好点的插件?7. javascript - node.js服务端渲染解疑8. html5 - rudy编译sass的时候有中文报错9. 为何 localStorage、sessionStorage 属于html5的范畴,但是为何 IE8却支持?10. javascript - 求助关于js正则问题
