python - The page opened using phantomjs is incomplete, what is the problem?
我想大声告诉你
我想大声告诉你 2017-05-18 10:58:18
0
3
815

When I use phantomjs to simulate login, there is no problem at all on the local windows, but it does not work when deployed to ubuntu14.04 in the server docker. I find that the page has not been loaded, and I have not found a solution. The simplest example will also fail. For example:

from selenium import webdriver
login_url = "https://www.baidu.com"
img_name = './img.png'
if __name__ == '__main__':
    driver = webdriver.PhantomJS()
    driver.implicitly_wait(20)
    driver.get(login_url)
    driver.save_screenshot(img_name)

I have tried implicitly waiting for loading; forced waiting for sleep; adjusting the window size; and the domain names on the page can all be pinged. Nothing is solved. I wonder if something is wrong when installing phantomjs? First, I installed it using apt-get, but --version prompted an error. Then the answer I found according to this error was to download the compressed package from the official website, install it and configure the environment variables. I did the same, and this problem occurred.

Environment:
ubuntu14.04 in docker
python2.7
phantomjs 2.1.1 is installed from the compressed package downloaded from the official website

Screenshot of the last loaded interface:

我想大声告诉你
我想大声告诉你

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!