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. mac连接阿里云docker集群,已经卡了2天了,求问?2. 为什么我ping不通我的docker容器呢???3. docker网络端口映射,没有方便点的操作方法么?4. vim - docker中新的ubuntu12.04镜像,运行vi提示,找不到命名.5. docker-compose 为何找不到配置文件?6. debian - docker依赖的aufs-tools源码哪里可以找到啊?7. html5和Flash对抗是什么情况?8. 百度地图api - Android 百度地图 集成了定位,导航 相互的jar包有冲突?9. golang - 用IDE看docker源码时的小问题10. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?

网公网安备