user2694765 user2694765 - 1 year ago 343
Python Question

Python: Selenium with PhantomJS empty page source

I'm having trouble with Selenium and PhantomJS on Windows7 when I want to get the source of the page of an URL.

returns only
. I've put a sleep before
but it didn't help.

This is my code:

from selenium import webdriver
browser = webdriver.PhantomJS('phantomjs-1.9.7-windows\phantomjs.exe')
url = 'myurl'
print browser.page_source

On Linux with the same version of PhantomJS it works perfectly. Also it works on Windows Server 2003.

Answer Source

by default phantomjs use SSLv3, but many sites after bug in ssl migrate to tls. That's why you has blank page. use service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any']

browser = webdriver.PhantomJS('phantomjs-1.9.7-windows\phantomjs.exe', service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any'])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download