程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

I can't connect to a proxy using Selenium in Python

发布于2024-11-26 22:19     阅读(93)     评论(0)     点赞(19)     收藏(5)


First of all, I'm sure the proxy is definitely working. I can use it when I try it from Windows's own proxy settings, but I can't connect to the proxy with Selenium.

(Chrome, driver, and Selenium are up to date)

Here’s my code:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import WebDriverException

# Proxy ayarları
proxy_host = ""
proxy_port = ""
proxy_user = ""
proxy_pass = ""
proxy_url = f"http://{proxy_user}:{proxy_pass}@{proxy_host}:{proxy_port}"

# Chrome seçeneklerini ayarlama
chrome_options = Options()
chrome_options.add_argument("--ignore-certificate-errors")
chrome_options.add_argument(f'--proxy-server={proxy_url}')

# ChromeDriver'ı başlatma
chrome_driver_path = "driver/chromedriver.exe"
service = Service(chrome_driver_path)

try:
    driver = webdriver.Chrome(service=service, options=chrome_options)
    driver.get("https://www.google.com")
    print("Page Source:", driver.page_source)
except WebDriverException as e:
    print("WebDriverException:", e)
finally:
    driver.quit()

I asked AI and opened a topic in the forums, but I couldn't find a solution. My goal is to connect to a Webdriver using a proxy.


解决方案


暂无回答



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:https://www.pythonheidong.com/blog/article/2046120/ddcafdac02b923842e8a/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

19 0
收藏该文
已收藏

评论内容:(最多支持255个字符)