代理 + 硒 [英] Proxies + Selenium

查看:47
本文介绍了代理 + 硒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 selenium 还很陌生,我正在构建一个访问网站并输入一个术语然后提交的机器人.问题是您只能提交一定次数,然后所使用的 IP 地址才会被服务器阻止以发送垃圾邮件.有没有办法在每次打开新的 chrome 浏览器时实现代理轮换.

Hi I am fairly new to selenium and I am building a bot that visits a website and enters a term then submits. The issue is that you can only Submit a certain amount of times before the IP address used gets blocked by the server for spam. Is there a way I can implement a proxy rotation every time it opens up a new chrome browser.

推荐答案

了解您使用的浏览器很重要,因为不同浏览器的设置略有不同.

It would be important to know which browser you are using because the settings differ a bit from browser to browser.

以下是如何在 Chrome 中使用代理的示例:

Here is an example of how to use a proxy with Chrome:

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

PROXY = "1.111.111.1:8080" #your proxy

chrome_options = WebDriverWait.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)

chrome = webdriver.Chrome(chrome_options=chrome_options)
chrome.get("yourwebsite.com")

这篇关于代理 + 硒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆