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 - 在 model里定義的 引用表模型時,model為undefined。2. python3.x - c++調用python33. css3 - 沒明白盒子的height隨width的變化這段css是怎樣實現的?4. atom開始輸入!然后按tab只有空格出現沒有html格式出現5. css3 - 這個右下角折角用css怎么畫出來?6. javascript - 一個關于客戶端和前端通信的疑惑?7. javascript - webpack熱加載配置不生效8. debian - docker依賴的aufs-tools源碼哪里可以找到?。?/a>9. java - 根據月份查詢多個表里的內容怎么實現好?10. android - 課程表點擊后浮動后邊透明可以左右滑動的界面是什么?
