我将phantomjs webdriver用于RPA实现。尝试使用以下代码加载一个网址:
webDriver.get(url);
问题是我可以手动转到此url(只需将其复制到浏览器中的地址行中)。它加载正常。但是当涉及到phantomjs时,它无法加载。我认为这可能与ssl协议有关,因此请为phantomjs设置以下选项:
--ignore-ssl-errors=true
--ssl-protocol=any
--web-security=true
还是一样。在调试模式下,尝试加载url时收到以下日志:
[DEBUG] HTTP Request - URI /session/1ed10cc0-ddc6-11e8-87f5-2f782befb71d/url
[DEBUG] HTTP Request - Method POST
[DEBUG] HTTP Request - HTTP Version 1.1
[DEBUG] HTTP Request - Query String
[DEBUG] HTTP Request - Receiving Header "Accept" = "application/json, image/png"
[DEBUG] HTTP Request - Receiving Header "Content-Type" = "application/json; charset=utf-8"
[DEBUG] HTTP Request - Receiving Header "Content-Length" = "141"
[DEBUG] HTTP Request - Receiving Header "Host" = "localhost:64560"
[DEBUG] HTTP Request - Receiving Header "Connection" = "Keep-Alive"
[DEBUG] HTTP Request - Method POST/PUT
[DEBUG] HTTP Request - Content Body: {"url":"myHiddenUrl"}
[DEBUG] WebPage - updateLoadingProgress: 56
[DEBUG] WebPage - updateLoadingProgress: 58
[DEBUG] WebPage - updateLoadingProgress: 61
[DEBUG] WebPage - updateLoadingProgress: 63
[DEBUG] WebPage - updateLoadingProgress: 66
[DEBUG] WebPage - updateLoadingProgress: 69
[DEBUG] WebPage - updateLoadingProgress: 72
[DEBUG] WebPage - updateLoadingProgress: 74
[DEBUG] WebPage - updateLoadingProgress: 77
[DEBUG] WebPage - updateLoadingProgress: 80
[DEBUG] Network - Resource request error: QNetworkReply::NetworkError(OperationCanceledError) ( "Operation canceled" ) URL: "http://localhost:8080/idea/style/kendo/fonts/glyphs/WebComponentsIcons.ttf?gedxeo"
[DEBUG] WebPage - updateLoadingProgress: 100
[DEBUG] WebPage - updateLoadingProgress: 10
[DEBUG] WebPage - setupFrame ""
[DEBUG] HTTP Response - Status Code 500 Internal Server Error
[DEBUG] HTTP Response - Sending Header "Cache" = "no-cache"
[DEBUG] HTTP Response - Sending Header "Content-Length" = "54132"
[DEBUG] HTTP Response - Sending Header "Content-Type" = "application/json;charset=UTF-8"
因此,您看到有500错误。但是我不知道可能有什么关系。我没有手动遇到这样的问题。可以带有请求标头吗? 在此先感谢您提供任何帮助。
答案 0 :(得分:0)
在您的请求似乎无效的地方,您可能缺少一些POST
请求参数。
您可以手动加载URL
,从而缩小范围并支持上述声明。
确保发送的请求信息没有丢失任何内容。