【问题标题】:Is there any way to bypass Google proxy block in Selenium webdriver?有没有办法绕过 Selenium webdriver 中的 Google 代理阻止?
【发布时间】:2020-12-11 04:27:24
【问题描述】:

我正在制作一个应用程序(在 Chrome 中使用 Selenium webdriver),它可以在 Google 上搜索指定的查询 (http://www.google.com/search?query),但每次搜索它时我都想更改我的 IP,所以我使用了代理。

问题是 Google 阻止了我使用的每个代理。反正有绕过它吗?也许我使用了错误类型的代理? (我尝试过 HTTP 和 HTTPS 代理,但每次都被阻止)

也许我的代码错了?:

from selenium import webdriver
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
options.add_argument("disable-extensions")
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
options.add_argument(f"--proxy-server=ip:port")

driver = Chrome(options=options, executable_path="C:/WebDriver/bin/chromedriver.exe")
driver.get("http://www.google.com/search?query")

这可能是代理质量的问题吗?

【问题讨论】:

    标签: python python-3.x selenium selenium-webdriver proxy


    【解决方案1】:

    Google 已在 Google Chrome 76 及更高版本中完全删除了对 FTP 的代理支持。您可以使用火狐或边缘。我尝试使用 Firefox 并能够启动:

    options = Options()
    options.binary_location = "C:\Program Files\Mozilla Firefox\Firefox.exe"
    options.add_argument("disable-extensions")
    options.add_argument("start-maximized")
    options.add_argument(f"--proxy-server=ip:port")
    
    driver = webdriver.Firefox(executable_path=r'..\drivers\geckodriver.exe', options=options)
    

    导入:

    from selenium import webdriver
    from selenium.webdriver.firefox.options import Options
    

    【讨论】:

    • 仍然是同一个 Google 阻止了我的请求并告诉我进行验证码...
    猜你喜欢
    • 2020-04-15
    • 2016-07-06
    • 2019-07-08
    • 2011-12-11
    • 1970-01-01
    • 2020-12-29
    • 1970-01-01
    • 2019-10-20
    • 1970-01-01
    相关资源
    最近更新 更多