ClericPy / ichrome

Chrome controller for Humans, based on Chrome Devtools Protocol(CDP) and python3.7+.
https://pypi.org/project/ichrome/
MIT License
227 stars 29 forks source link

examples_async.py运行报错 #123

Closed william2ct closed 1 year ago

william2ct commented 1 year ago

win10 pip安装ichrome 运行报错如下: CRITICAL 2023-03-14 11:37:51 [ichrome] iChrome.py(594): Start testing flatten=True. Traceback (most recent call last): File "C:\SVN\Alipay\iChrome.py", line 606, in test_all() File "C:\SVN\Alipay\iChrome.py", line 598, in test_all loop.run_until_complete(test_examples()) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 647, in run_until_complete return future.result() File "C:\SVN\Alipay\iChrome.py", line 440, in test_examples await test_init_tab(chromed) File "C:\SVN\Alipay\iChrome.py", line 361, in test_init_tab async with chromed.connect_tab(index=None, auto_close=True) as tab: File "C:\SVN\Alipay\venv\lib\site-packages\ichrome\async_utils.py", line 120, in aenter return await super().aenter() File "C:\SVN\Alipay\venv\lib\site-packages\ichrome\async_utils.py", line 89, in aenter raise ChromeRuntimeError( ichrome.exceptions.ChromeRuntimeError: Tab init failed. index=None, chrome=<Chrome(Using unsafe HTTP verb GET to invoke /json/new. This action supports only PUT verb.): http://127.0.0.1:9222>

大概意思可能是说/json/new只支持HTTP PUT方法。

解决: async_utils.py AsyncChrome中有一个put_server()方法,新增加一个put_server()方法。在new_tab()方法中调用put_server即可。

ClericPy commented 1 year ago

PUT /json/new?{url}

我昨天刚试过可以正常运行, 看了官方提示居然真的是 PUT 请求了, 真够折腾的, 老出这种不向后兼容的升级. 我跟着官方改一下这个请求的方法, 非常感谢提醒, 不知道为啥我这里测试昨天还正常来着

ClericPy commented 1 year ago

刚才跑了下确实 GET 不能用了, 刚升级的 chrome 确实和老版本这个地方不一样. 坑爹, 还好有你提醒, 不然新版本都挂了...

ichrome 3.1.1 fix 这个问题

william2ct commented 1 year ago

我是这两天需要做chrome的一些自动化发现了ichrome ichrome这东西很好,非常适合我现在使用。要谢谢你才对 : )

ClericPy commented 1 year ago

我是这两天需要做chrome的一些自动化发现了ichrome ichrome这东西很好,非常适合我现在使用。要谢谢你才对 : )

哈哈, 当初刚有 CDP 时候摸索的, 实际上我现在看到这代码都恶心的不想维护了... 软件工程学的越多越感觉以前写的都是一坨s...

能帮到大家就好