Ich versuche PhantomJS (in Windows) mit Selen in Python zu verwenden, um etwas Web Scraping zu machen.
Ich habe den neuesten PhantomJS-Build von der Website heruntergeladen und entzippe ihn dann. Danach habe ich versuchtPhantomJS aus Selen - Python
from selenium import webdriver
browser = webdriver.PhantomJS()
Die Antwort war
WebDriverException: 'phantomjs' executable needs to be in PATH.
Dann habe ich versucht, den Weg zu schreiben,
browser = webdriver.PhantomJS('path_to/phantomjs.exe')
habe ich auch versucht, ein "zu setzen r 'vor dem Weg. Die Antwort war ein exxeption in HTML:
WebDriverException: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Notification: Gateway Timeout</title>
<style type="text/css">
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color:#333333;
background-color: #ffffff;
}
h1 {
font-size: 18px;
font-weight: bold;
text-decoration: none;
padding-top: 0px;
color: #2970A6;
}
a:link {
color: #2970A6;
text-decoration: none;
}
a:hover {
color: #2970A6;
text-decoration: underline;
}
p.buttonlink {
margin-bottom: 24px;
}
.copyright {
font-size: 12px;
color: #666666;
margin: 5px 5px 0px 30px;
}
.details {
font-size: 14px;
color: #969696;
border: none;
padding: 20px 20px 20px 20px;
margin: 0px 10px 10px 35px;
}
.shadow {
border: 3px solid #9f9f9f;
padding: 10px 25px 10px 25px;
margin: 10px 35px 0px 30px;
background-color: #ffffff;
width: 600px;
-moz-box-shadow: 3px 3px 3px #cccccc;
-webkit-box-shadow: 3px 3px 3px #cccccc;
box-shadow: 3px 3px 3px #cccccc;
/* For IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='cccccc')";
/* For IE 5.5 - 7 */
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='cccccc');
}
.logo {
border: none;
margin: 5px 5px 0px 30px;
}
</style>
</head>
<body>
<div class="logo"></div><p> </p>
<div class="shadow">
<h1>This Page Cannot Be Displayed</h1>
<p>
The system cannot communicate with the external server ( 127.0.0.1 ).
The Internet server may be busy, may be permanently down, or may be
unreachable because of network problems.
</p>
<p>
Please check the spelling of the Internet address entered.
If it is correct, try this request later.
</p>
<p>
If you have questions, please contact
your corporate network administrator
and provide the codes shown below.
</p>
</div>
<div class="details"><p>
Date: Mon, 30 May 2016 12:30:14 CEST<br />
Username: <br />
Source IP: 10.202.210.98<br />
URL: POST http://127.0.0.1/wd/hub/session<br />
Category: Uncategorized URLs<br />
Reason: UNKNOWN<br />
Notification: GATEWAY_TIMEOUT
</p></div>
</body>
</html>
ich offen habe diesen Code in eine Chrome-Sitzung und es öffnet sich die Firewall-Seite meines Unternehmens. Die Nachricht lautet "Das System kann nicht mit dem externen Server kommunizieren (127.0.0.1).". Ich kann websrape mit Chrome oder Firefox Treibern, aber ich habe dieses Problem mit PhantomJS.
Können Sie mir helfen?
Ich habe auch festgestellt, dass die URL verwendet wird POST http://127.0.0.1/wd/hub/session. Gibt es eine Möglichkeit, dies zu ändern? Es ist eindeutig ein Problem mit der Firewall des Unternehmens. –