PhantomJS使用Python Selenium返回Access Denied

时间:2017-11-17 00:28:49

标签: 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 server <p>
Reference #18.4adedd58.1510878066.6ade65ca


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

这就是我开始PhantomJS

的方式
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

0 个答案:

没有答案