[PhantomJS] Https Redirect Problem with PhantomJS + Selenium

xiaoxiao2021-02-28  160

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'])
转载请注明原文地址: https://www.6miu.com/read-39813.html

最新回复(0)