python - pyspider翻頁(yè)問(wèn)題?
問(wèn)題描述
想要爬取愛(ài)卡汽車(chē)的每個(gè)汽車(chē)的口碑,但是在翻頁(yè)問(wèn)題總是進(jìn)不去,無(wú)論是用chorme還是自帶的css selector helper抓取到的CSS PATH都無(wú)法翻頁(yè),請(qǐng)求幫助,代碼如下
#!/usr/bin/env python# -*- encoding: utf-8 -*-# Created on 2017-03-21 12:57:03# Project: test03import refrom pyspider.libs.base_handler import *class Handler(BaseHandler): crawl_config = { } @every(minutes=24 * 60) def on_start(self):self.crawl(’http://newcar.xcar.com.cn/price/’, callback=self.index_page) @config(age=10 * 24 * 60 * 60) def index_page(self, response):for each in response.doc(’a[href^='http']’).items(): if re.match('http://newcar.xcar.com.cn/d', each.attr.href, re.U): self.crawl(each.attr.href, callback=self.list_page) def list_page(self, response):for each in response.doc(’body > p.demio_wp > p > ul > li:nth-child(6) > a’).items(): self.crawl(each.attr.href, callback=self.list_page1)def list_page1(self, response):for each in response.doc(’.review_gml_tit > .more’).items(): self.crawl(each.attr.href, callback=self.detail_page) #翻頁(yè),問(wèn)題出在下面這里for each in response.doc(’body > p.review_main > p.review_left > p > p.review_comments > p.review_comments_dl > p.pagers > a:nth-child(2)’).items(): self.crawl(each.attr.href, callback=self.list_page1)@config(priority=2) def detail_page(self, response):return { 'branch':response.doc(’#nav_ps > em > a’).text(), 'text':response.doc(’body > p.review_main > p.review_left > p > p.review_comments > p.review_comments_dl > dl > dd’).text(), }
問(wèn)題解答
回答1:評(píng)論是 javascript 加載的。
相關(guān)文章:
1. [python2]local variable referenced before assignment問(wèn)題2. 求救一下,用新版的phpstudy,數(shù)據(jù)庫(kù)過(guò)段時(shí)間會(huì)消失是什么情況?3. mysql - 如何在有自增id的情況下,讓其他某些字段能不重復(fù)插入4. python小白,關(guān)于函數(shù)問(wèn)題5. django - Python error: [Errno 99] Cannot assign requested address6. angular.js - 百度支持_escaped_fragment_嗎?7. java - 線上應(yīng)用,如果數(shù)據(jù)庫(kù)操作失敗的話(huà)應(yīng)該如何處理?8. node.js - win 下 npm install 遇到了如下錯(cuò)誤 會(huì)導(dǎo)致 無(wú)法 run dev么?9. python小白 關(guān)于類(lèi)里面的方法獲取變量失敗的問(wèn)題10. Python2中code.co_kwonlyargcount的等效寫(xiě)法
