Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 硒+;搔痒中的幻影_Javascript_Python_Selenium_Scrapy_Phantomjs - Fatal编程技术网

Javascript 硒+;搔痒中的幻影

Javascript 硒+;搔痒中的幻影,javascript,python,selenium,scrapy,phantomjs,Javascript,Python,Selenium,Scrapy,Phantomjs,我正在尝试使用Selenium和PhantomJS来获取网站的动态内容。这是我的密码 class judge(Spider): name = "judge" start_urls = ["http://wenshu.court.gov.cn/List/List?sorttype=1&conditions=searchWord+2+AJLX++%E6%A1%88%E4%BB%B6%E7%B1%BB%E5%9E%8B:%E6%B0%91%E4%BA%8B%E6%A1%88%E

我正在尝试使用Selenium和PhantomJS来获取网站的动态内容。这是我的密码

class judge(Spider):
    name = "judge"
    start_urls = ["http://wenshu.court.gov.cn/List/List?sorttype=1&conditions=searchWord+2+AJLX++%E6%A1%88%E4%BB%B6%E7%B1%BB%E5%9E%8B:%E6%B0%91%E4%BA%8B%E6%A1%88%E4%BB%B6"]

    def init_driver(self):
        driver = webdriver.Chrome()
        return driver 

    def parse(self,response):
        driver = self.init_driver()
        driver.get(self.start_urls[0])
        sel = Selector(text=driver.page_source)
        self.logger.info(u'---------------Parsing----------------')
        print sel.xpath("//div[@class='dataItem'][1]/table/tbody/tr[1]/td/div[@class='wstitle']/a/text()").extract()
        self.logger.info(u'---------------success----------------')
当我使用
driver=webdriver.Chrome()
尝试我的脚本时,sel.xpath(//div[@class='dataItem']提供了所需的内容,并且一切正常。但是当我改用
driver=webdriver.PhantomJS()
时,sel.xpath(//div[@class='dataItem']为空。我尝试在
driver.get()之后使用WebDriverWait)
使页面完全加载,但不起作用。

您可以尝试以下方法:

driver = webdriver.PhantomJS('add your directory of phantomjs here')
你可以试试这个:

driver = webdriver.PhantomJS('add your directory of phantomjs here')

您是否尝试过在使用phantom验证phantom是否实际加载到动态内容时拍摄屏幕截图?我已通过
response.page_source
检查了响应,但phantom似乎没有加载动态内容。我不知道出了什么问题……@Y_KL您能对其进行排序吗out@Volatil3我想问题出在我身上s PhantomJS与所有网页不兼容。如果我错了,请纠正我。您是否尝试在使用phantom验证phantom是否实际加载到动态内容时拍摄屏幕截图?我已通过
response.page\u source
检查了响应,但phantom似乎没有加载动态内容。我不知道w帽子坏了……@Y_-KL你能把它分类吗out@Volatil3我认为问题在于PhantomJS不能与所有网页兼容。如果我错了,请纠正我。