import requests
from itertools import cycle
from lxml.html import fromstring
def get_proxies():
url = 'https://free-proxy-list.net/'
response = requests.get(url)
parser = fromstring(response.text)
proxies = set()
for i in parser.xpath('//tbody/tr')[:10]:
if i.xpath('.//td[7][contains(text(),"yes")]'):
proxy = ":".join([i.xpath('.//td[1]/text()')[0], i.xpath('.//td[2]/text()')[0]])
proxies.add(proxy)
return proxies
url="https://api.ipify.org?format=json"
x=requests.get(url,proxies={"http": next(proxy_pool), "https": next(proxy_pool)})
print(x.json())
并且回复是{u'ip':u'87.228.29.154'}
我可以在发出python请求时获取代理ip的地址 但我想在selenium中做到这一点我尝试了几个解决方案,如
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", "190.186.58.198")
profile.set_preference("network.proxy.http_port", 53281)
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)
但是在访问网址时,我得到了自己的ip。是否有任何方法可以让我在选中时检查