提问人:churmond 提问时间:11/1/2023 更新时间:11/1/2023 访问量:141
Selenium Proxy Scraper - Chrome 到 Firefox
Selenium Proxy Scraper - Chrome to Firefox
问:
谁能帮我把这个 Chrome/Chromedriver Selenium 脚本变成一个与 Firefox/Geckodriver 兼容的脚本? 或者,如果有人有一些类似的脚本,他们不介意分享 /\ :) 我也尝试过 proxybroker,但它也给了我错误,我可能会为其创建一个新帖子。
from selenium import webdriver
from selenium.webdriver.common.by import By
import chromedriver_autoinstaller # pip install chromedriver-autoinstaller
chromedriver_autoinstaller.install() # To update your chromedriver automatically
driver = webdriver.Chrome()
# Get free proxies for rotating
def get_free_proxies(driver):
driver.get('https://sslproxies.org')
table = driver.find_element(By.TAG_NAME, 'table')
thead = table.find_element(By.TAG_NAME, 'thead').find_elements(By.TAG_NAME, 'th')
tbody = table.find_element(By.TAG_NAME, 'tbody').find_elements(By.TAG_NAME, 'tr')
headers = []
for th in thead:
headers.append(th.text.strip())
proxies = []
for tr in tbody:
proxy_data = {}
tds = tr.find_elements(By.TAG_NAME, 'td')
for i in range(len(headers)):
proxy_data[headers[i]] = tds[i].text.strip()
proxies.append(proxy_data)
return proxies
free_proxies = get_free_proxies(driver)
print(free_proxies)
答: 暂无答案
评论