Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

获取 articles 报错 #99

Open
mashihua opened this issue Jun 26, 2017 · 2 comments
Open

获取 articles 报错 #99

mashihua opened this issue Jun 26, 2017 · 2 comments

Comments

@mashihua
Copy link

估计是字符编码集的问题,报错:

ERROR:wxpy.api.bot:
An error occurred in <function mp at 0x11212d8c0>.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/wxpy/api/bot.py", line 440, in process
ret = config.func(msg)
File "bot.py", line 15, in mp
print(msg.articles)
File "/usr/local/lib/python2.7/site-packages/wxpy/api/messages/message.py", line 226, in articles
tree = ETree.fromstring(self.raw['Content'])
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1311, in XML
parser.feed(text)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1651, in feed
self._parser.Parse(data, 0)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 52-56: ordinal not in range(128)

@mashihua
Copy link
Author

self.raw['Content'] 返回下面数据:
<msg> <appmsg appid="" sdkver="0"> <title><![CDATA[我是月岛雯]]></title> <des><![CDATA[大家好,我是月岛雯。一个爱做白日梦的小书虫,课余时间喜欢写文字和画画。]]></des> <action></action> <type>5</type> <showtype>1</showtype> <soundtype>0</soundtype> <content><![CDATA[]]></content> <contentattr>0</contentattr> <url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzAwNzM0MzM3MA==&mid=100000019&idx=1&sn=a39877765dd9b8669e5e3675ed221d46&chksm=1b7edd762c09546094937bcdfc6cd3ad0c0297db0e5bbcd8d10cd075d8ae3828467058d903b6&scene=0&previewkey=iVLUC2qWkggjSD4IGAHaasNS9bJajjJKzz%25252F0By7ITJA%25253D#rd]]></url> <lowurl><![CDATA[]]></lowurl> <appattach> <totallen>0</totallen> <attachid></attachid> <fileext></fileext> </appattach> <extinfo></extinfo> <mmreader> <category type="20" count="1"> <name><![CDATA[月岛雯的白日梦]]></name> <topnew> <cover><![CDATA[http://mmbiz.qpic.cn/mmbiz_jpg/qzDoowr9vfqaw1oLW1Fcr8DXdOW6zdKITHZbO4NzUvNYKah2cVrI1ReIkdaLZ9He1GTFN0PKOWZFP0g6ngQTng/640?wxtype=jpeg&wxfrom=0]]></cover> <width>0</width> <height>0</height> <digest><![CDATA[]]></digest> </topnew> <item> <itemshowtype>0</itemshowtype> <title><![CDATA[我是月岛雯]]></title> <url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzAwNzM0MzM3MA==&tempkey=HFlpfVSAQ7cBI4tOiMRgYd8fzX9ib8ibh3j89ImFpSMu9F%2BPP0nQ5vAKsyM1eBWj2Jvqo4LgGdogaGIlPcG3oUU00%2FdKKsrRoya1yJQOy0GtNWEMc8XHY9eU%2BsA9VnK4oi06yGVigrOMQaof5XqB9A%3D%3D&chksm=1b7edd762c09546094937bcdfc6cd3ad0c0297db0e5bbcd8d10cd075d8ae3828467058d903b6&scene=0&previewkey=iVLUC2qWkggjSD4IGAHaasNS9bJajjJKzz%252F0By7ITJA%253D#rd]]></url> <shorturl><![CDATA[]]></shorturl> <longurl><![CDATA[]]></longurl> <pub_time>1498466356</pub_time> <cover><![CDATA[http://mmbiz.qpic.cn/mmbiz_jpg/qzDoowr9vfqaw1oLW1Fcr8DXdOW6zdKITHZbO4NzUvNYKah2cVrI1ReIkdaLZ9He1GTFN0PKOWZFP0g6ngQTng/640?wxtype=jpeg&wxfrom=0|0|0]]></cover> <tweetid></tweetid> <digest><![CDATA[大家好,我是月岛雯。一个爱做白日梦的小书虫,课余时间喜欢写文字和画画。]]></digest> <fileid>100000023</fileid> <sources> <source> <name><![CDATA[月岛雯的白日梦]]></name> </source> </sources> <styles></styles> <native_url></native_url> <del_flag>0</del_flag> <contentattr>0</contentattr> <play_length>0</play_length> <play_url></play_url> <player><![CDATA[]]></player> <template_op_type>0</template_op_type> <weapp_username><![CDATA[]]></weapp_username> <weapp_path><![CDATA[]]></weapp_path> <weapp_version>0</weapp_version> <weapp_state>0</weapp_state> </item> </category> <publisher> <username><![CDATA[gh_b39d1ba4e381]]></username> <nickname><![CDATA[月岛雯的白日梦]]></nickname> </publisher> <template_header></template_header> <template_detail></template_detail> <forbid_forward>0</forbid_forward> </mmreader> <thumburl><![CDATA[http://mmbiz.qpic.cn/mmbiz_jpg/qzDoowr9vfqaw1oLW1Fcr8DXdOW6zdKITHZbO4NzUvNYKah2cVrI1ReIkdaLZ9He1GTFN0PKOWZFP0g6ngQTng/640?wxtype=jpeg&wxfrom=0]]></thumburl> </appmsg><fromusername><![CDATA[gh_b39d1ba4e381]]></fromusername><appinfo><version>0</version><appname><![CDATA[月岛雯的白日梦]]></appname><isforceupdate>1</isforceupdate></appinfo></msg>

@baifengbai
Copy link

my_friend = bot.friends().search('白风') 楼主搜索中文名称出错怎么解决呢

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

No branches or pull requests

2 participants