custom headers in PhantomJS selenium WebDriver

0

I need to establish through headers, the browser I use. Because I use PhantomJS, the website I want to go to says that it is not compatible, so now I want to pass the phantomJS as a chrome or firefox.

I know it's possible, but I do not find the answer on the internet that helps me in particular.

Use PhantomJS 2.1.1.0 in windows 7.

    
asked by Diego Lopez 03.01.2018 в 16:07
source

1 answer

0

This is the code that has worked for me:

desired_capabilities = DesiredCapabilities.PHANTOMJS.copy()
desired_capabilities['phantomjs.page.customHeaders.User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) ' \
                                                                  'AppleWebKit/537.36 (KHTML, like Gecko) ' \
                                                                  'Chrome/39.0.2171.95 Safari/537.36'
browser = webdriver.PhantomJS("C:/Users/DIEGO/Documents/diego/scraping/phantomjs.exe",desired_capabilities=desired_capabilities)

I hope it helps you.

    
answered by 03.01.2018 в 17:11