У меня есть рабочий скребок, но я не могу понять, почему запросы не проходят через установленный мной прокси.Я пробовал три разных подхода, которые нашел, но ни один из них не работает.Может быть, это что-то на настройке сервера, я должен проверить?
Вот три варианта, которые я безуспешно попробовал.
def SetProxy1():
options = Options()
myProxy = '191.6.69.137:20183'
proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': myProxy,
'ftpProxy': myProxy,
'sslProxy': myProxy,
})
options.headless = True
options.add_argument('-headless')
driver = webdriver.Firefox(options=options, proxy=proxy)
return driver
def SetProxy2():
options = Options()
options.add_argument("--headless")
proxy = "191.6.69.137"
proxy_port = 20183
proxy_profile = webdriver.FirefoxProfile()
proxy_profile.set_preference("network.proxy.type", 1)
proxy_profile.set_preference("network.proxy.http",proxy)
proxy_profile.set_preference("network.proxy.http_port",int(proxy_port))
proxy_profile.set_preference("network.proxy.https",proxy)
proxy_profile.set_preference("network.proxy.https_port",int(proxy_port))
proxy_profile.set_preference("network.proxy.ssl",proxy)
proxy_profile.set_preference("network.proxy.ssl_port",int(proxy_port))
proxy_profile.set_preference("network.proxy.ftp",proxy)
proxy_profile.set_preference("network.proxy.ftp_port",int(proxy_port))
proxy_profile.set_preference("network.proxy.socks",proxy)
proxy_profile.set_preference("network.proxy.socks_port",int(proxy_port))
proxy_profile.update_preferences()
browser = webdriver.Firefox(firefox_profile=proxy_profile, firefox_options=options)
return browser
def SetProxy3():
PROXY = "191.6.69.137"
PORT = 20183
desired_capability = webdriver.DesiredCapabilities.FIREFOX
desired_capability['proxy']={
"proxyType":"manual",
"httpProxy":PROXY,
"httpProxyPort": PORT,
"ftpProxy":PROXY,
"ftpProxyPort": PORT,
"sslProxy":PROXY,
"sslProxyPort" : PORT
}
options = Options()
options.add_argument("--headless")
driver = webdriver.Firefox(firefox_options=options,capabilities=desired_capability)
return driver