ehForwarderBot / efb-wechat-slave

A channel for EH Forwarder Bot.
GNU Affero General Public License v3.0
458 stars 62 forks source link

[BUG] 报错 xml.parsers.expat.ExpatError: mismatched tag: line 64, column 4,~/.ehforwarderbot/profiles/default/blueset.wechat 不存在wxpy.pkl文件 #142

Closed Martinho0330 closed 2 years ago

Martinho0330 commented 2 years ago

版本信息 Version Info

EH Forwarder Bot
Version: 2.1.1
Python version:
3.8.10 

Master channel:
   2.3.1

Slave channel:
   2.0.7

Middleware:
   No middleware is enabled.

问题描述 Describe the bug

重现步骤 To Reproduce

截图 Screenshots

Verbose 日志 Log

Verbose 日志 ``` 2022-09-09 12:09:19,559 [Level 99]: plugins.blueset.wechat.WeChatChannel (__init__.console_qr_code; __init__.py:195) Confirm on your phone. Traceback (most recent call last): File "/usr/local/bin/ehforwarderbot", line 8, in sys.exit(main()) File "/usr/local/lib/python3.8/dist-packages/ehforwarderbot/__main__.py", line 335, in main init(conf) File "/usr/local/lib/python3.8/dist-packages/ehforwarderbot/__main__.py", line 135, in init coordinator.add_channel(cls(instance_id=instance_id)) File "/usr/local/lib/python3.8/dist-packages/efb_wechat_slave/__init__.py", line 160, in __init__ self.authenticate('console_qr_code', first_start=True) File "/usr/local/lib/python3.8/dist-packages/efb_wechat_slave/__init__.py", line 672, in authenticate self.bot: wxpy.Bot = wxpy.Bot(cache_path=str(efb_utils.get_data_path(self.channel_id) / "wxpy.pkl"), File "/usr/local/lib/python3.8/dist-packages/efb_wechat_slave/vendor/wxpy/api/bot.py", line 85, in __init__ self.core.auto_login( File "/usr/local/lib/python3.8/dist-packages/efb_wechat_slave/vendor/itchat/components/register.py", line 32, in auto_login self.login(enableCmdQR=enableCmdQR, picDir=picDir, qrCallback=qrCallback, File "/usr/local/lib/python3.8/dist-packages/efb_wechat_slave/vendor/itchat/components/login.py", line 58, in login status = self.check_login() File "/usr/local/lib/python3.8/dist-packages/efb_wechat_slave/vendor/itchat/components/login.py", line 171, in check_login if process_login_info(self, r.text): File "/usr/local/lib/python3.8/dist-packages/efb_wechat_slave/vendor/itchat/components/login.py", line 211, in process_login_info for node in xml.dom.minidom.parseString(r.text).documentElement.childNodes: File "/usr/lib/python3.8/xml/dom/minidom.py", line 1969, in parseString return expatbuilder.parseString(string) File "/usr/lib/python3.8/xml/dom/expatbuilder.py", line 926, in parseString return builder.parseString(string) File "/usr/lib/python3.8/xml/dom/expatbuilder.py", line 224, in parseString parser.Parse(string, True) xml.parsers.expat.ExpatError: mismatched tag: line 64, column 4 ``` 请在下方贴出您的 Verbose 日志。如果您对隐私有所顾虑,您可以自行 隐去隐私信息、或 GPG 加密至 BD6B65EC00638DC9083781D5D4B65BB1A106200A。 ``` 2022-09-09 12:12:43,109 [Level 99]: ehforwarderbot.__main__ (__main__.init; __main__.py:129) Initializing slave blueset.wechat... 2022-09-09 12:12:43,113 [DEBUG]: urllib3.util.retry (retry.from_int; retry.py:229) Converted retries value: 30 -> Retry(total=30, connect=None, read=None, redirect=None, status=None) 2022-09-09 12:12:43,113 [DEBUG]: urllib3.util.retry (retry.from_int; retry.py:229) Converted retries value: 30 -> Retry(total=30, connect=None, read=None, redirect=None, status=None) 2022-09-09 12:12:43,118 [DEBUG]: urllib3.connectionpool (connectionpool._new_conn; connectionpool.py:957) Starting new HTTPS connection (1): login.weixin.qq.com:443 2022-09-09 12:12:43,356 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428) https://login.weixin.qq.com:443 "GET / HTTP/1.1" 200 87920 2022-09-09 12:12:43,583 [DEBUG]: itchat (hotreload.load_login_status; hotreload.py:64) No such file, loading login status failed. 2022-09-09 12:12:43,584 [INFO]: itchat (login.login; login.py:49) Getting uuid of QR code. 2022-09-09 12:12:43,587 [DEBUG]: urllib3.connectionpool (connectionpool._new_conn; connectionpool.py:957) Starting new HTTPS connection (1): login.weixin.qq.com:443 2022-09-09 12:12:43,820 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428) https://login.weixin.qq.com:443 "GET /jslogin?appid=&fun=new HTTP/1.1" 200 64 2022-09-09 12:12:43,824 [INFO]: itchat (login.login; login.py:52) Downloading QR code. 2022-09-09 12:12:43,956 [Level 99]: plugins.blueset.wechat.WeChatChannel (__init__.console_qr_code; __init__.py:219) EWS: Please scan the QR code with your camera, screenshots will not work. (gcKJdqQCkQ==, 0) 2022-09-09 12:12:43,957 [INFO]: itchat (login.login; login.py:55) Please scan the QR code to log in. 2022-09-09 12:12:50,267 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428) https://login.weixin.qq.com:443 "GET /cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=&tip=1&r=-1053024&_=1662725563 HTTP/1.1" 200 16 2022-09-09 12:12:50,269 [Level 99]: plugins.blueset.wechat.WeChatChannel (__init__.console_qr_code; __init__.py:195) Confirm on your phone. 2022-09-09 12:12:50,269 [INFO]: itchat (login.login; login.py:65) Please press confirm on your phone. 2022-09-09 12:12:51,372 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428) https://login.weixin.qq.com:443 "GET /cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=&tip=1&r=-1053024&_=1662725571 HTTP/1.1" 200 16 2022-09-09 12:12:52,435 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428) https://login.weixin.qq.com:443 "GET /cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=&tip=1&r=-1053024&_=1662725572 HTTP/1.1" 200 183 2022-09-09 12:12:52,438 [DEBUG]: urllib3.connectionpool (connectionpool._new_conn; connectionpool.py:957) Starting new HTTPS connection (1): wx.qq.com:443 2022-09-09 12:12:52,815 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428) https://wx.qq.com:443 "GET /cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=&uuid=&lang=zh_CN&scan=1662725570 HTTP/1.1" 200 996 ```

备注 Additional context

将 File "/usr/lib/python3.8/xml/dom/expatbuilder.py", line 224, in parseString parse的内容打印了下,如下,发现第64行是,刚好是head结束,怀疑是meta不是标准的xml符号,这里看逻辑应该是访问pub.weixin.com的返回正常的xml验证信息,估计还是验证失败跳去了登录页

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, viewport-fit=cover" />
    <meta name="color-scheme" content="light dark">
    <title>微信网页版</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        font-family: Microsoft YaHei,-apple-system-font,Helvetica Neue,Helvetica,sans-serif;
        font-size: 14px;
        line-height: 1.6;
      }
      .msg {
        width: 400px;
        margin: 0 auto;
        text-align: center;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
      }
      .msg-title {
        font-size: 24px;
        font-weight: 400;
        color: #191919;
      }
      @media (prefers-color-scheme: dark) {
        .msg-title {
          color: rgba(255, 255, 255, 0.9);
        }
      }
      .msg-desc {
        margin-top: 10px;
        font-weight: 400;
        color: #999999;
        word-break: break-word;
      }
      .msg-button-area {
        margin-top: 72px;
      }
      .msg-button {
        width: 228px;
        height: 32px;
        background-color: #07C160;
        border: 0;
        color: #fff;
        border-radius: 3px;
        cursor: pointer;
        display: inline-block;
        vertical-align: middle;
        line-height: 32px;
        text-decoration: none;
      }
      .msg-button:hover {
        background-color: #06ad56;
      }
    </style>
  </head>
  <body>
    <div class="msg">
      <div class="msg-text-area">
        <p class="msg-desc">For&nbsp;the&nbsp;security&nbsp;of&nbsp;your&nbsp;account,&nbsp;you&nbsp;cannot&nbsp;log&nbsp;in&nbsp;to&nbsp;Weixin&nbsp;for&nbsp;Web.&nbsp;You&nbsp;can&nbsp;go&nbsp;to&nbsp;https://weixin.qq.com/&nbsp;to&nbsp;download&nbsp;the&nbsp;Weixin&nbsp;app&nbsp;and&nbsp;log&nbsp;in.</p>
      </div>
          </div>
  <script src="//res.wx.qq.com/t/wx_fed/webwx/res/static/vendor/vendor_327b7c1.js"></script><script>webpackJsonp([0],[function(n,exports){n.exports=""}]);/* vhtml-webpack-plugin version: 0.1.38 */</script></body>
</html>
blueset commented 2 years ago

感谢协助 debug。 在打印出的 XML 的倒数第五行,可以发现

For&nbsp;the&nbsp;security&nbsp;of&nbsp;your&nbsp;account,&nbsp;you&nbsp;cannot&nbsp;log&nbsp;in&nbsp;to&nbsp;Weixin&nbsp;for&nbsp;Web.&nbsp;You&nbsp;can&nbsp;go&nbsp;to&nbsp;https://weixin.qq.com/&nbsp;to&nbsp;download&nbsp;the&nbsp;Weixin&nbsp;app&nbsp;and&nbsp;log&nbsp;in.

For the security of your account, you cannot log in to Weixin for Web. You can go to https://weixin.qq.com/ to download the Weixin app and log in.

说明该账号被禁止使用 Web WC。

t-satoru commented 1 year ago

Commit 22816dec4f12c44db2f6ac63a355b3b2777bd6d5 增加的统信UOS伪装代码看样子没有同步到pypi 先卸载来自pypi的EWS,再使用pip3 install git+https://github.com/ehForwarderBot/efb-wechat-slave.git的方式重新安装EWS,即可使用UOS的UA绕过微信的限制。