PhantomJS在单击lin后不会导航到下一页

2024-09-27 21:30:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我对PhantomJS有一个奇怪的问题,或者我是新手。我正在尝试登录新蛋网通过使用PhantomJS通过硒。我正在使用Python。问题是,当我使用Firefox作为驱动程序时,它工作得很好,但一旦我将PhantomJS设置为驱动程序,它就不会转到下一页,因此会给出以下消息:

Exception Message: u'{"errorMessage":"Unable to find element with id \'UserName\'","request":{"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"89","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:55372","User-Agent":"Python-urllib/2.7"},"httpVersion":"1.1","method":"POST","post":"{\\"using\\": \\"id\\", \\"sessionId\\": \\"aaff4c40-6aaa-11e4-9cb1-7b8841e74090\\", \\"value\\": \\"UserName\\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/aaff4c40-6aaa-11e4-9cb1-7b8841e74090/element"}}' ; Screenshot: available via screen 

我在截图后发现幻影无法浏览页面和脚本的原因。我怎么解决这个问题?我试过的代码片段如下:

导入请求 从bs4导入BeautifulSoup 从时间导入睡眠 从selenium import webdriver 导入日期时间

^{pr2}$

我甚至把sleep放进去了,但这没什么区别。在


Tags: idjson消息application驱动程序时间exceptionusername
1条回答
网友
1楼 · 发布于 2024-09-27 21:30:26

当第二页的内容类型不正确时,我在PhantomJS中遇到了这种情况。一个普通的浏览器只会动态地解释内容,而幻影只是默默地死去。在

相关问题 更多 >

    热门问题