PhantomJS返回Python Selenium拒绝的访问

PhantomJS返回Python Selenium拒绝的访问,python,selenium,phantomjs,Python,Selenium,Phantomjs,我已经使用PhantomJS和Python selenium来废弃一个网站有一段时间了,现在我得到了这个页面 <html><head> <title>Access Denied</title> </head><body> <h1>Access Denied</h1> You don't have permission to access "http://elpais.com/" on this se

我已经使用PhantomJS和Python selenium来废弃一个网站有一段时间了,现在我得到了这个页面

<html><head>
<title>Access Denied</title>
</head><body>
<h1>Access Denied</h1>

You don't have permission to access "http://elpais.com/" on this server <p>
Reference #18.4adedd58.1510878066.6ade65ca


</p></body></html>

这是您的完整源代码吗?由于驱动程序总是无法找到我要查找的元素,我运行了
print(driver.page\u source)
,这就是我得到的?!我的意思是,你必须共享你的完整代码,带有导入…我在原始版本中添加了导入,可能会有一个冷却期,持续几天,如果你有动态IP,我会重新启动它。在最坏的情况下,请将Selenium与代理一起使用,并将其保留在my中以备将来使用,以避免长时间访问页面。只需让您的请求休眠一小部分时间。这是您的完整源代码吗?由于驱动程序总是无法找到我要查找的元素,我运行了
print(driver.page\u source)
,这就是我得到的?!我的意思是,你必须共享你的完整代码,带有导入…我在原始版本中添加了导入,可能会有一个冷却期,持续几天,如果你有动态IP,我会重新启动它。在最坏的情况下,请将Selenium与代理一起使用,并将其保留在my中以备将来使用,以避免长时间访问页面。只需让你的请求睡眠一小部分时间。
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

def open_headless_browser():
    dcap = dict(DesiredCapabilities.PHANTOMJS)
    dcap["phantomjs.page.settings.userAgent"] = (
        "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53 "
        "(KHTML, like Gecko) Chrome/15.0.87"
    )
    driver = webdriver.PhantomJS(desired_capabilities=dcap)
    driver.set_window_size(1024, 768)
    driver.implicitly_wait(1)
return driver