Here is the code I'm trying to execute:

from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities import time ua = dict(DesiredCapabilities.PHANTOMJS) ua["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36") service_args = ['--proxy=109.228.147.75:45554','--proxy-type=socks5','--load-images=false','--ignore-ssl-errors=true'] browser = webdriver.PhantomJS(desired_capabilities=ua, service_args=service_args) browser.set_window_size(1920, 1080) browser.get('http://www.ip-adress.com/') time.sleep(10) browser.save_screenshot('screen_test.png') 

If you use socks5, then when executing the code PhantomJS can not load the site, remaining in limbo, you can wait for eternity and nothing will happen. If you complete the PhantomJS process, then IDLE will abort on the command:

 browser.get('http://www.ip-adress.com/') 

In Mozilla (not in the code, but simply in the window) with the same proxy site opens.

If you change the proxy to https type, then everything will work.

However, through socks5 http://example.com/ is loaded. That is just him. No other site is loading. => Because of this, I suspect that there is a problem with DNS queries, but how to fix this?

Python 3.5 / Selenium 3.0.1 / PhantomJS 2.1.1

    1 answer 1

    It's all about the proxy itself. I did not fully understand what the chip is, but as a result, you need to check the proxy for the working DNS Forwarding. There are just a lot of working socks, but with an adequate DNS F, I somehow got much smaller.

    As I understand it, PhantomJS, using socks5 by default, uses DNS Forwarding by default, which is why it waits for the server to respond to it. However, the settings are as in Mozile:

    enter image description here

    Phantom does not have, and it is impossible to disable DNS query proxying at Phantom.

    Although I do not exclude that it is not right so far, and the real answer is different.

    Thank))

    • one
      Thank you for publishing the solution found. - Nick Volynkin