【问题标题】:phantomjs not loading instagram and pintersest webpagesphantomjs 不加载 instagram 和 pinterestest 网页
【发布时间】:2016-09-25 17:00:27
【问题描述】:

我在 Ubuntu Server 16.04.1 下的 python 2.7.12 中使用 PhantomJS 2.1.1,显示来自 pyvirtualdisplay

PhantomJS 无法加载 instagram 交互式 dom 页面 (https://www.instagram.com/accounts/login/)。页面代码应该在

<span id="react-root"></span>

但它仍然是空的。

Instagram 页面在 Mac OS X 10.11.6 下的 python 2.7.10 中使用 PhantomJS 2.1.1 正确加载; Ubuntu Server 下的 PhantomJS 可以正确加载许多其他网站(twitter、tumblr 等),所以我猜 Ubuntu Server 中缺少一些模块但不明白是哪一个。

它既不能加载https://www.pinterest.com/login/,但使用简单的curl正确加载了这个页面。

有人可以帮忙吗? 谢谢。

这是python代码:

from selenium import webdriver
from pytvirtualdisplay import Display

display = Display(visible=0,size=(800,600))
display.start()

browser = webdriver.PhantomJS()
browser.set_window_size(800, 600)
browser.get('https://www.instagram.com/accounts/login/')

browser.get('https://www.pinterest.com/login/')

ghostdriver.log

[INFO  - 2016-09-12T16:08:37.057Z] GhostDriver - Main - running on port 49739
[INFO  - 2016-09-12T16:08:37.933Z] Session [2a14fc60-7903-11e6-a755-53e4799f55f3] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1","webSecurityEnabled":true}
[INFO  - 2016-09-12T16:08:37.933Z] Session [2a14fc60-7903-11e6-a755-53e4799f55f3] - page.customHeaders:  - {}
[INFO  - 2016-09-12T16:08:37.933Z] Session [2a14fc60-7903-11e6-a755-53e4799f55f3] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"2.1.1","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"linux-unknown-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO  - 2016-09-12T16:08:37.934Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 2a14fc60-7903-11e6-a755-53e4799f55f3

更新: 使用 phantomjs 安装

sudo apt-get install phantomjs

它正确地加载了整个页面。但是这个包缺少一些重要的第三方依赖(比如find_element Atom)。

使用 phantomjs 安装

npm install phantomjs-prebuilt

它没有正确加载页面(即使它已获得所有第三方 Atom)。

有没有办法使用通过 apt-get 安装的可执行文件和通过 npm 安装的第三方 Atoms?

【问题讨论】:

    标签: javascript python-2.7 phantomjs instagram pinterest


    【解决方案1】:

    已解决。

    我解决了直接从 git 存储库在 Ubuntu Server 上编译 phantomjs 的问题。 所以可能预编译的二进制文件不完整。

    详情请看:http://phantomjs.org/build.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-01
      • 2017-02-21
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多