A few days ago, I was writing a python script with PhantomJS and Selenium, but the redirection doesn’t work properly.
Problem
For example,
driver.get("https://redirect-to-login.example.com")
driver.page_source
The page_source
is empty.
Solution
I found this article(https://stackoverflow.com/questions/29358269/handling-redirection-w-phantomjs-selenium).
The reason is that when doing https redirect, it is possible SSL handshake will fail.
So we need to add --ignore-ssl-errors=true
when initializing the driver
driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true'])