python - scrapy爬蟲不能循環(huán)運(yùn)行?
問題描述
scrapy只能爬取一個(gè)頁面上的鏈接,不能持續(xù)運(yùn)行爬完全站,以下是代碼,初學(xué)求指導(dǎo)。
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:是不是爬得太快讓封了
相關(guān)文章:
1. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE語法實(shí)現(xiàn)存在即更新應(yīng)該使用哪個(gè)標(biāo)簽?2. mysql - 怎么生成這個(gè)sql表?3. mysql儲(chǔ)存json錯(cuò)誤4. 哭遼 求大佬解答 控制器的join方法怎么轉(zhuǎn)模型方法5. mysql - 表名稱前綴到底有啥用?6. Navicat for mysql 中以json格式儲(chǔ)存的數(shù)據(jù)存在大量反斜杠,如何去除?7. 編輯成功不顯示彈窗8. 怎么php怎么通過數(shù)組顯示sql查詢結(jié)果呢,查詢結(jié)果有多條,如圖。9. mysql - 數(shù)據(jù)庫表中,兩個(gè)表互為外鍵參考如何解決10. sql語句 - 如何在mysql中批量添加用戶?
