python selenium 怎么打开 Chrome 并且能设置代理,请问可以指导小弟一下吗。
更新时间:2023-02-03 20:02
最满意答案
这个代理是在IE里设置的。 不是用chrome,方向错了。 你搜索一下《使用Python给IE设置代理》。 可以找到答案。下面一些代码,看看有没用。 def changeIEProxy(keyName, keyValue): pathInReg = 'Software\Microsoft\Windows\CurrentVersion\Internet Settings' key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER,pathInReg, 0, win32con.KEY_ALL_ACCESS) win32api.RegSetValueEx(key, keyName, 0, win32con.REG_SZ, keyValue) win32api.RegCloseKey(key)所说IE浏览器的代理内容在注册表中 『HKEYCURRENTUSER\Software\Microsoft\Windows\CurrentVersion\Internet Settings』这里存着
其他回答
简要说一下自己的思路 1,有两个代理可用,所以爬的时候随机选取一个 2,复制了一些user-agnet,随机选一个 3,爬一次随机睡眠3~6s 这样大概爬200次左右,就不能再 爬了
相关问答
更多-
python selenium 怎么打开 Chrome 并且能设置代理,请问可以指导小弟一下吗。[2023-02-03]
这个代理是在IE里设置的。 不是用chrome,方向错了。 你搜索一下《使用Python给IE设置代理》。 可以找到答案。下面一些代码,看看有没用。 def changeIEProxy(keyName, keyValue): pathInReg = 'Software\Microsoft\Windows\CurrentVersion\Internet Settings' key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER,pathInReg, 0, wi ... -
我不知道这是否仍然与您相关,如果我使用Python时我的解决方案也适合您,而我使用R. 我已经使用带有Chrome网络驱动程序的RSelenium软件包在R中编写了自动网络抓取代码。 就像你一样,我想同时使用谷歌浏览器的多个实例与不同的谷歌浏览器配置文件,比如“配置文件1”和“配置文件2”,我在谷歌浏览器中相应地创建了它们。 R让我轻松打开两个配置文件之一的selenium web-driver,例如“Profile 1”(记住这是R): # Define profile directory: prof1 ...
-
如何选择使用Selenium时启用的Chrome扩展程序[复制](How to select Chrome extensions to enable when using Selenium [duplicate])[2022-09-26]
您可以使用ChromeOptions类或DesiredCapabilities完成此操作。 为此,您必须具有.crx文件并使用驱动程序实例加载该文件。 import os from selenium import webdriver from selenium.webdriver.chrome.options import Options executable_path = "path_to_webdriver" os.environ["webdriver.chrome.driver"] = execu ... -
使用无代理Chrome通过Python为Selenium禁用代理(Disable proxy via Python for Selenium with headless Chrome)[2022-10-18]
尝试这个: chrome_options.add_argument('--no-proxy-server') Try this: chrome_options.add_argument('--no-proxy-server') -
使用选项类: from selenium.webdriver.chrome.options import Options options = Options() options.binary_location = "c:\myproject\chromeportable\chrome.exe" # you may need some other options #options.add_argument('--no-sandbox') #options.add_argument('--no-default- ...
-
您需要指定您的chrome驱动程序所在的路径 。 从此处下载所需平台的Chrome驱动器 。 将该文件放置在您的代码所在的目录或无论您想要的位置。 通过以下代码链接您的chromedriver.exe : browser = webdriver.Chrome(executable_path=r"chromedriver.exe") 或将executable_path更改为存储您的chromedriver的位置。 你完成了! 这应该做到这一点。 希望能帮助到你! 评论你是否还有任何疑问。 You need ...
-
**您需要在您的网址中添加协议http或https ,例如https://www.gmail.com 如果不工作,则提供geckodriver.exe或chromedriver.exe路径不是firefox或chrome exe路径 从这里下载geckodriver或从这里下载chromedriver.exe 并设置属性如: System.setProperty("webdriver.gecko.driver", "drive path\\geckodriver.exe"); WebDriver netDr ...
-
在python-selenium webdriver.Ie只是执行IEDriver.exe并通过webdriver.Remote连接到它的快捷方式。 例如,您可以从命令行启动IEDriver.exe : > IEDriverServer.exe Started InternetExplorerDriver server (64-bit) 2.39.0.0 Listening on port 5555 并使用以下代码替换webdriver.Ie() : webdriver.Remote(command_ex ...
-
问题是由于最近对--test-type开关行为的改变造成的。 ChromeDriver问题跟踪器中对此进行了描述 。 解决方法是禁用此开关。 这是我的代码更改: // Add ChromeDriver-specific capabilities through ChromeOptions. ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("excludeSwitches", Arrays.asList("t ...
-
尝试使用以下代码,如有任何问题,请告知我们: from selenium import webdriver chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("test-type") driver = webdriver.Chrome(chrome_options=chrome_options) driver.get('https://www.google.com') Try to use following c ...