所以我有下面的代码,它仍然显示真实的IP。也没有产生错误。抱歉不能分享真实的代理详细信息:)
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium.webdriver.firefox.options import Options
PROXY_HOST = "206.41.127.230"
PROXY_PORT = "603230"
USERNAME = "xxx"
PASSWORD = "xx"
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", PROXY_HOST)
profile.set_preference("network.proxy.http_port", PROXY_PORT)
profile.set_preference("network.proxy.socks_username", USERNAME)
profile.set_preference("network.proxy.socks_password", PASSWORD)
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options, executable_path=r'/usr/local/bin/geckodriver', firefox_profile=profile)
driver.get('https://httpbin.org/ip')
html = driver.page_source
print(html)
driver.quit()