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 - 百度echarts series數據更新問題2. MySQL客戶端吃掉了SQL注解?3. java - 我設置了cookie的max age,但是cookie依然在關閉游覽器后消失了4. css3 - [CSS] 動畫效果 3D翻轉bug5. javascript - JS設置Video視頻對象的currentTime時出現了問題,IE,Edge,火狐,都可以設置,反而chrom卻...6. python小白的基礎問題 關于while循環的嵌套7. java固定鍵值轉換,使用枚舉實現字典?8. php自學從哪里開始?9. phpstady在win10上運行10. 求大神幫我看看是哪里寫錯了 感謝細心解答
