from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.common.proxy import Proxy
from selenium.webdriver.common.proxy import ProxyType
def PhantomJS(ip):
proxy = Proxy(
{
'proxyType': ProxyType.MANUAL,
'httpProxy': ip # 代理ip和端口
}
)
desired_capabilities = DesiredCapabilities.PHANTOMJS.copy()
# 把代理ip加入到技能中
proxy.add_to_capabilities(desired_capabilities)
# PhantomJS 路径
driver = webdriver.PhantomJS(
executable_path=r"C:UsersAdministratorAppDataLocalProgramsPythonPython36phantomjs.exe",
desired_capabilities=desired_capabilities
)
return driver
喜欢的话点点加关注,不定期更新有用知识