我正在编写一个python脚本来抓取一个网站。
我已经设置了selenium来使用PhantomJS()因为我在使用firefox读取PATH var时遇到了问题。
这是我到目前为止:
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.set_window_size(1024, 768)
driver.get("http://www.google.com")
运行时出现此错误代码:
> line 58, in __init__
> desired_capabilities=desired_capabilities) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py",
> line 92, in __init__
> self.start_session(desired_capabilities, browser_profile) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py",
> line 179, in start_session
> response = self.execute(Command.NEW_SESSION, capabilities) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py",
> line 236, in execute
> self.error_handler.check_response(response) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py",
> line 163, in check_response
> raise exception_class(value) selenium.common.exceptions.WebDriverException: Message: <!DOCTYPE HTML
> PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.
> org/TR/html4/strict.dtd"> <HTML><HEAD><TITLE>Not Found</TITLE> <META
> HTTP-EQUIV="Content-Type" Content="text/html;
> charset=us-ascii"></HEAD> <BODY><h2>Not Found</h2> <hr><p>HTTP Error
> 404. The requested resource is not found.</p> </BODY></HTML>
不确定究竟发生了什么......还有其他人遇到过这个问题并有解决方案吗?