Closed QQ-War closed 2 years ago
如下四个链接,第一个链接就稳定不转telegraph。
[3天前,这个小国,狠狠“帮美国教训”了中国和俄罗斯?: http://mp.weixin.qq.com/s?__biz=MjM5OTYwOTM0Nw==&mid=2650229747&idx=1&sn=366826a0aa3a63dfb69a1ec08d6dbde3&chksm=bf3b3e9f884cb78903777eeab58841dfd16a4344276caa9b0b20dd39cfea3fa1b2d6df40e67c#rd]
[“宁可自己遭罪也不想看到它们受伤害”: http://mp.weixin.qq.com/s?__biz=MjM5OTYwOTM0Nw==&mid=2650229747&idx=3&sn=d104846d1fc1602bc1d26183ac836b0c&chksm=bf3b3e9f884cb789949fe700f180e0181768f2eda72a1acd92e01889e7c9fe959ec8d06820ee#rd]
[上海努力做到蔬菜礼包全覆盖、深圳建立国内首个宠物方舱、少林寺进军房地产丨酷玩日爆: http://mp.weixin.qq.com/s?__biz=MjM5OTYwOTM0Nw==&mid=2650229747&idx=7&sn=7e9388084fd7d3d6eb346f60537724e3&chksm=bf3b3e9f884cb7892d84dcd85691508971b4aefde5f0a466de614b61a672115fd5887157e422#rd]
更多日志,可以看到是middleware失败。
Tay 09 09:36:48 computername ehforwarderbot[173558]: {'event': 'EventFriendMsg', ****, 'msg': '<?xml version="1.0"?>\r\n
Tay 09 09:36:54 computer_name ehforwarderbot[173558]: [https://api.telegra.ph:443](https://api.telegra.ph/) "POST /createPage HTTP/1.1" 200 58
58
表示 Telegraph API 返回的消息长度,这么短的长度,很明显是返回了一个错误,至于是啥,我猜是内容长度超限。
自己跑了一下, 最后print有点问题,回来再看看具体原因吧。
page = tg.process_url('http://mp.weixin.qq.com/s?__biz=MjM5OTYwOTM0Nw==&mid=2650229747&idx=1&sn=366826a0aa3a63dfb69a1ec08d6dbde3&chksm=bf3b3e9f884cb78903777eeab58841dfd16a4344276caa9b0b20dd39cfea3fa1b2d6df40e67c#rd') (这里没有问题) print(tg.publish(page['title'], page['author'], page['content'])) Traceback (most recent call last): File "
", line 1, in File "/home/pcloud/.local/lib/python3.8/site-packages/efb_mp_instantview_middleware/telegraph.py", line 59, in publish return response['result']['url'] KeyError: 'result'
没有 result 就是 Telegraph API 不能成功生成文章,所以不会返回 result ,通常原因就是文章太长,超过 64KB
修改了下publich,直接返回respones,确实是太大了。这个有办法解决吗?
print(tg.publish) <bound method Telegraph.publish of <debug_QQ_war.Telegraph object at 0x7fef7e0d55b0>> print(tg.publish(page['title'], page['author'], page['content'])) {'ok': False, 'error': 'CONTENT_TOO_BIG'}
没有办法,这是硬性限制
写了个修改判断大小,如果超过65536就删除attrs属性的补丁。
还是没啥用,有的文章过于长,估计只能从把一篇分拆成几篇入手来考虑设计。但是Json要分拆真的好难。
the first one didn't, while the second success. I didn't find the difference.
Tay 07 21:55:03 computer_name ehforwarderbot[157844]: received event: EventGroupMsg Tay 07 21:55:03 computer_name ehforwarderbot[157844]: {'event': 'EventGroupMsg', 'robot_wxid': '删除', 'robot_name': '', 'type': 'share', 'from_wxid': '删除', 'from_name': '删除', 'final_from_wxid': '删除', 'final_from_name': '删除', 'to_wxid': '删除', 'msgid': '1772797919', 'msg': '\r\n \r\n <![CDATA[删除]]> \r\n <![CDATA[删除]]> \r\n \r\n 5 \r\n 0 \r\n \r\n <![CDATA[删除URL]]> \r\n \r\n \r\n 0 \r\n \r\n \r\n\r\n <![CDATA[删除URL]]> \r\n <![CDATA[]]> \r\n <![CDATA[]]> \r\n <![CDATA[0]]> \r\n <![CDATA[]]> \r\n <![CDATA[]]> \r\n <![CDATA[]]> \r\n\r\n \r\n \r\n <![CDATA[]]> \r\n \r\n fromusername><![CDATA[25984984653187515@openim]]\r\n \r\n \r\n \r\n \r\n \r\n \r\n '}
Tay 07 21:55:03 computer_name ehforwarderbot[157844]: 2022-04-07 21:55:03,889 [DEBUG]: efb_telegram_master.slave_message (slave_message.send_message; slave_message.py:91)
Tay 07 21:55:03 computer_name ehforwarderbot[157844]: [None] Slave message delivered to ETM.
Tay 07 21:59:19 computer_name ehforwarderbot[157844]: {'event': 'EventGroupMsg', 'robot_wxid': '删除', 'robot_name': '', 'type': 'share', 'from_wxid': '删除', 'from_name': '删除', 'final_from_wxid': '删除', 'final_from_name': '删除', 'to_wxid': '删除', 'msgid': '1772797920', 'msg': '\r\n \r\n <![CDATA[删除]]> \r\n <![CDATA[删除]]> \r\n \r\n 5 \r\n 0 \r\n \r\n <![CDATA[删除URL]]> \r\n \r\n \r\n 0 \r\n \r\n \r\n\r\n <![CDATA[删除URL]]> \r\n <![CDATA[]]> \r\n <![CDATA[]]> \r\n <![CDATA[0]]> \r\n <![CDATA[]]> \r\n <![CDATA[]]> \r\n <![CDATA[]]> \r\n\r\n \r\n \r\n <![CDATA[]]> \r\n \r\n fromusername><![CDATA[25984984653187515@openim]]\r\n \r\n \r\n \r\n \r\n \r\n \r\n '}
Tay 07 21:59:19 computer_name ehforwarderbot[157844]: 2022-04-07 21:59:19,167 [DEBUG]: urllib3.connectionpool (connectionpool._get_conn; connectionpool.py:266)
Tay 07 21:59:19 computer_name ehforwarderbot[157844]: Resetting dropped connection: mp.weixin.qq.com
Tay 07 21:59:21 computer_name ehforwarderbot[157844]: 2022-04-07 21:59:21,216 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428)
Tay 07 21:59:21 computer_name ehforwarderbot[157844]: https://mp.weixin.qq.com:443 "GET /s?t=pages/video_detail_new&scene=1&vid=wxv_2338765966769258496&__biz=MzI0NjA4MzY5OA==&mid=2247502084&idx=3&sn=e51dc6aa941fbdf1e42ec4e0425aba38&vidsn= HTTP/1.1" 200 23072
Tay 07 21:59:21 computer_name ehforwarderbot[157844]: 2022-04-07 21:59:21,240 [DEBUG]: urllib3.connectionpool (connectionpool._new_conn; connectionpool.py:957)
Tay 07 21:59:21 computer_name ehforwarderbot[157844]: Starting new HTTPS connection (3): api.telegra.ph:443
Tay 07 21:59:21 computer_name ehforwarderbot[157844]: 2022-04-07 21:59:21,990 [DEBUG]: urllib3.connectionpool (connectionpool._make_request; connectionpool.py:428)
Tay 07 21:59:21 computer_name ehforwarderbot[157844]: https://api.telegra.ph:443 "POST /createPage HTTP/1.1" 200 243
Tay 07 21:59:21 computer_name ehforwarderbot[157844]: 2022-04-07 21:59:21,992 [DEBUG]: efb_telegram_master.slave_message (slave_message.send_message; slave_message.py:91)
Tay 07 21:59:21 computer_name ehforwarderbot[157844]: [None] Slave message delivered to ETM.