我正在尝试使用具有用户和密码的代理,但它无法工作并显示真实的IP。代码如下:
PROXY_HOST = "xxx.xxx.xxx.xxx"
PROXY_PORT = 60000
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", "user")
profile.set_preference("network.proxy.socks_password", "pwd")
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)
driver.maximize_window()
driver.get('https://httpbin.org/ip')
html = driver.page_source
print(html)
代理IP本身正在运行,因为我使用Python requests
库验证了它。