aknuds1
aknuds1

Reputation: 68127

Why can't PhantomJS open my Web page?

I'm trying to load this Web page from PhantomJS 2 on Ubuntu 15.04, via Python 2/Selenium, but the request simply times out. Why is it unable to open the page?

I've tried the following Python script:

from selenium import webdriver

timeout = 30

driver = webdriver.PhantomJS()
driver.set_page_load_timeout(timeout)
driver.set_window_size(1024, 768)
driver.get('https://f8790d1e-aknuds1.node.tutum.io/')

This eventually times out after 30 seconds.

Upvotes: 0

Views: 780

Answers (1)

Vaviloff
Vaviloff

Reputation: 16856

I've edited your script so that it now loads the site and succesfully produces a screenshot.

I think the problem was that you've set a too short timeout. It taken out, site will eventually load. Also you have to account for the misconfigured SSL certificate on the demo.

Update: added time measurements. From my geolocation script runs for 13-14 seconds.

from selenium import webdriver
import time

# timeout = 10
# driver.set_page_load_timeout(timeout)

start = time.time()
driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true', '--ssl-protocol=ANY'])
driver.set_window_size(1024, 768)
driver.get('https://f8790d1e-aknuds1.node.tutum.io/')
driver.save_screenshot('screen.png')
driver.quit()

end = time.time()
print(end - start)

Upvotes: 3

Related Questions