鍍金池/ 問答/Python  網(wǎng)絡(luò)安全  HTML/ pyspider使用phantomjs,webui調(diào)試沒問題,運(yùn)行不執(zhí)行,只有第

pyspider使用phantomjs,webui調(diào)試沒問題,運(yùn)行不執(zhí)行,只有第一個(gè)index_page的調(diào)用。

pyspider使用phantomjs獲取上一頁的鏈接,并獲取當(dāng)前頁的內(nèi)容。

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Created on 2017-12-26 09:25:21
# Project: adc8868

from pyspider.libs.base_handler import *


class Handler(BaseHandler):
    crawl_config = {
        'itag': 'v11'
    }

    @every(minutes=24 * 60)
    def on_start(self):
        self.crawl('http://www.cnblogs.com/adc8868/p/7814893.html', callback=self.index_page)

    @config(age=0)
    def index_page(self, response):
        # 將本頁地址交給詳情頁抓取處理
        self.crawl(response.url, callback=self.detail_page)

        
    @config(fetch_type="js")
    def detail_page(self, response):
        # 獲取到上一頁,下一頁的鏈接,并進(jìn)行抓取
        for prev in response.doc("#post_next_prev a").items():
            self.crawl(prev.attr.href, callback=self.index_page)
                
        return {
            "url": response.url,
            "title": response.doc('title').text(),
        }

webui里調(diào)試執(zhí)行采集腳本可以運(yùn)行,點(diǎn)擊任務(wù)列表那里的run就不行,只執(zhí)行一次index_page的代碼就結(jié)束了,根本就沒有執(zhí)行detail_page。detail_page是以fetch_type="js"方式采集數(shù)據(jù)的。
請(qǐng)問是什么原因?如何解決?

回答
編輯回答
傲寒

你也沒說你遇到什么問題了啊

2017年12月13日 16:15
編輯回答
情未了

我也遇見過這問題,detail_page同樣是以fetch_type="js"方式來采集數(shù)據(jù)的。
但是什么也沒改,不知道幾分鐘后又點(diǎn)了下,發(fā)現(xiàn)居然可以了,還不知道為什么,尷尬

2017年8月14日 10:01