Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行出错 #7

Open
ivoidcat opened this issue Jan 20, 2021 · 7 comments
Open

运行出错 #7

ivoidcat opened this issue Jan 20, 2021 · 7 comments

Comments

@ivoidcat
Copy link

Wait for QRCode Scan...0/15turns
Login Succeed.
Task launching...
navigate to https://weread.qq.com/web/reader/50532a905cde3050538da2b
preparing to scan "竞争战略"
scanning chapter "推荐序1"
Traceback (most recent call last):
File "/Users/zhigangyang/development/WXRead/WX.py", line 15, in
weread.scan2pdf('https://weread.qq.com/web/reader/50532a905cde3050538da2b')
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/WeReadScan/WeRead.py", line 171, in scan2pdf
self.shot_full_displayed_element(context, f'{png_name}.png')
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/WeReadScan/WeRead.py", line 60, in shot_full_displayed_element
element.screenshot(file_name)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 585, in screenshot
png = self.screenshot_as_png
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 567, in screenshot_as_png
return base64.b64decode(self.screenshot_as_base64.encode('ascii'))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 557, in screenshot_as_base64
return self._execute(Command.ELEMENT_SCREENSHOT)['value']
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: unhandled inspector error: {"code":-32000,"message":"Cannot take screenshot with 0 width."}

@Algebra-FUN
Copy link
Owner

Algebra-FUN commented Jan 20, 2021

请问你使用的是ChromeDriver吗?因为不同的WebDriver在headless模式下的渲染方式是不一样的,所以有些浏览器可能会造成element没有全部渲染
推荐使用ChromeDriver

@ivoidcat
Copy link
Author

是使用的ChromeDriver。

@Algebra-FUN Algebra-FUN added the bug Something isn't working label Mar 1, 2021
@Algebra-FUN
Copy link
Owner

请问你使用的是ChromeDriver吗?因为不同的WebDriver在headless模式下的渲染方式是不一样的,所以有些浏览器可能会造成element没有全部渲染
推荐使用ChromeDriver

是使用的ChromeDriver。

所以,没话说了?@Algebra-FUN
最近一次commits 显示2021年2月7日,也没解决这个问题,我下载了,还是报这个错误

@ivoidcat @snow212-cn
抱歉,没有及时回复,本人大三,学业繁忙,无暇顾及,望谅解

@Algebra-FUN
Copy link
Owner

image

Algebra-FUN added the bug label yesterday

⬆︎⬆︎⬆︎ 真是搞笑 ⬆︎⬆︎⬆︎。

@snow212-cn
bug fix不了被鸽,是个很正常的现象。github很多上千star的repo也有不少issues一鸽就是半年的。所以这很正常

@Algebra-FUN
Copy link
Owner

@snow212-cn

去掉headless无头选项,以有头模式(有窗口)运行,不报错了,但是,截取的图片又不全了! (0.8.2)
启用headless就疯狂报错
{"code":-32000,"message":"Cannot take screenshot with 0 width."}

截取完整全屏图片就是利用headless的特性,所以headless是需要的
(当然也有不通过headless进行截取全屏的方法,通过图片拼接的方式,但是不易实现)

启用headless就疯狂报错
{"code":-32000,"message":"Cannot take screenshot with 0 width."}
这个问题可能是webdriver和selenium自身的问题,不是我代码的问题
较为直接的检验方式,就是在你的环境下,写一个脚本,开启headless模式,直接screenshot,看看这个问题是否会出现:

  • 如果出现,那就是环境的问题
  • 如果不出现,那可能是我的代码引起的副作用导致的

当然如果你有兴趣的话,也可以自学一下selenium,没准你会有更好的解决方案,也欢迎大家讨论交流

@Algebra-FUN Algebra-FUN removed the bug Something isn't working label Mar 21, 2021
@wzt12
Copy link

wzt12 commented Jul 1, 2022

edge

@wzt12
Copy link

wzt12 commented Jul 1, 2022

哪个是可以运行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants