我正在浏览googleplay商店和应用程序的评论,由应用程序页面的URL指定。然后Selenium找到评论并向下滚动以加载所有评论。滚动部分工作正常,没有headless选项,我可以看到Selenium到达站点的末尾。不起作用的是保存html内容以供进一步分析。在
基于其他答案,我尝试了不同的方法来保存源代码。在
innerHTML = DRIVER.execute_script("return document.body.innerHTML")
或者
^{pr2}$两者都会导致相同的错误消息和异常。在
我的代码,用于滚动页面并加载所有评论
^{3}$日志文件,显示无限滚动已到达页面末尾,但无法保存该文件
10.09.19 16:12:00 - INFO - Durchlauf erfolgreich
10.09.19 16:12:13 - ERROR - Exception occurred
Traceback (most recent call last):
File "scraper.py", line 57, in <module>
innerHTML = DRIVER.execute_script("return document.body.innerHTML")
File "C:\Users\tenscher\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 636, in execute_script
'args': converted_args})['value']
File "C:\Users\tenscher\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\tenscher\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: [Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://marionette/content/proxy.js :: sendReply_ :: line 275" data: no]
最后一部分壁虎.log在
...
1568124670155 Marionette WARN TimedPromise timed out after 500 ms: stacktrace:
bail@chrome://marionette/content/sync.js:223:64
1568124693017 Marionette WARN TimedPromise timed out after 500 ms: stacktrace:
bail@chrome://marionette/content/sync.js:223:64
1568124734637 Marionette INFO Stopped listening on port 57015
[Parent 14684, Gecko_IOThread] WARNING: pipe error: 109: file z:/task_1560820494/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341
[Child 10464, Chrome_ChildThread] WARNING: pipe error: 109: file z:/task_1560820494/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341
[Parent 14684, Gecko_IOThread] WARNING: pipe error: 109: file z:/task_1560820494/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341
JavaScript error: resource:///modules/sessionstore/SessionStore.jsm, line 1639: TypeError: subject.QueryInterface is not a function
A content process crashed and MOZ_CRASHREPORTER_SHUTDOWN is set, shutting down
[Child 2508, Chrome_ChildThread] WARNING: pipe error: 109: file z:/task_1560820494/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341
[Child]
我想将页面保存为一个文件,然后在下一步解析html以提取评论。但是保存部分不能处理大页面。如果我在说100步后退出while循环并保存页面,它可以正常工作。在
NS_ERROR_FAILURE (0x80004005)
这是所有错误的一般错误,对于不适用更具体的错误代码的所有错误,都会发生这种错误。在
但是这个错误消息。。。在
…意味着木偶在试图读取/存储/复制
page_source()
时抛出了一个错误。在相关的HTML DOM可以帮助我们以更好的方式调试该问题。然而,问题似乎在于
page_source()
非常巨大,超过了木偶能够处理的最大值的最大值。可能你正在处理的是一个更大的string
。在解决方案
一个快速的解决方案是避免将
^{pr2}$page_source()
传递给变量并打印它以找出实际问题所在。在或者
奥特罗
您可以在以下网站找到相关讨论:
相关问题 更多 >
编程相关推荐