最新微信hook二次开发C#Demo之采集微信公众号文章
在文章【江南鹤微信hook二次开发C#Demo之获取消息代码】中说到,获取微信消息的方法,这次详细说一下怎么 在获取到的消息中获取微信公众号推送的文章。
在获取到的消息中根据消息类型id来区分消息
var msgType=nmHeler.Json_GetIntEx(RecvJson, “Type”);
其中 msgType== 49的才是公众号文章
通过解析消息内容获得消息的实例
var MsgInfo = new NMHelper.nmMsgInfo
{
RecvWxid = nmHeler.Json_GetString(RecvJson, "RecvWxid", true),
Wxid_1 = Wxid_1,
Nick_1 = Nick_1,
Msg = nmHeler.Json_GetString(RecvJson, "Msg", true),
Type = msgType,
State = nmHeler.Json_GetIntEx(RecvJson, "State"),
Time = nmHeler.Json_GetIntEx(RecvJson, "Time"),
IsSend = nmHeler.Json_GetIntEx(RecvJson, "Sender"),
LocalMsgID = nmHeler.Json_GetIntEx(RecvJson, "LocalID"),
ServerMsgID = nmHeler.Json_GetString(RecvJson, "ServerID", false),
//Wxid_1 = nmHeler.Json_GetString(RecvJson, "Wxid_1", true),
//Nick_1 = nmHeler.Json_GetString(RecvJson, "Nick_1", true),
Wxid_2 = nmHeler.Json_GetString(RecvJson, "Wxid_2", true),
Nick_2 = nmHeler.Json_GetString(RecvJson, "Nick_2", true),
//Msg = nmHeler.Json_GetString(RecvJson, "Msg", true),
Source = nmHeler.Json_GetString(RecvJson, "Source", true)
};
其中 msgInfo.Msg 是消息的具体内容,是个xml结构的字符串,内容如下
<msg>
<appmsg appid=”” sdkver=”0″>
<title><![CDATA[百度全员涨薪,那你的薪资呢?]]></title>
<des><![CDATA[据每日经济新闻,3月18日,需要此c#的源代码请+微信weixinhook,年终奖可能还要多半个月,实习生也会涨工资。]]></des>
<action></action>
<type>5</type>
<showtype>1</showtype>
<content><![CDATA[]]></content>
<contentattr>0</contentattr> <url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzI1NjMxNzUyNA==&mid=2247492567&idx=1&sn=7df7500a60b2e5273950e0e10b671674&chksm=ea2a22ecdd5dabfa63e21cfacfe972fd3b612ab5680c670f4208641b25ce0c1caff0578e4e03&scene=0&xtrack=1#rd]]></url>
<lowurl><![CDATA[]]></lowurl>
<appattach>
<totallen>0</totallen>
<attachid></attachid>
<fileext></fileext>
</appattach>
<extinfo></extinfo>
<mmreader>
<category type=”20″ count=”8″>
<name><![CDATA[自由职客]]></name>
<topnew>
<cover><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/oHIRnv852wvVLSSe2sgS9y626CQRGlenlwwBYrS6PaQLBKIExbuzesdQ5AI1FKP8scCBtxza2oUgJrD7Nl3ZFA/640?wxtype=jpeg&wxfrom=0]]></cover>
<width>0</width>
<height>0</height>
<digest><![CDATA[据每日经济新闻,3月18日,百度公司董事长李彦宏在内部沟通会上表示,全部员工工资会进行普调,且预算超去年,年终奖可能还要多半个月,实习生也会涨工资。]]></digest>
</topnew>
<item>
<itemshowtype>0</itemshowtype>
<title><![CDATA[百度全员涨薪,那你的薪资呢?]]></title> <url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzI1NjMxNzUyNA==&mid=2247492567&idx=1&sn=7df7500a60b2e5273950e0e10b671674&chksm=ea2a22ecdd5dabfa63e21cfacfe972fd3b612ab5680c670f4208641b25ce0c1caff0578e4e03&scene=0&xtrack=1#rd]]></url>
<shorturl><![CDATA[]]></shorturl>
<longurl><![CDATA[]]></longurl>
<pub_time>1584954006</pub_time>
<cover><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/oHIRnv852wvVLSSe2sgS9y626CQRGlenlwwBYrS6PaQLBKIExbuzesdQ5AI1FKP8scCBtxza2oUgJrD7Nl3ZFA/640?wxtype=jpeg&wxfrom=0]]></cover>
<tweetid></tweetid>
<digest><![CDATA[据每日经济新闻,3月18日,百度公司董事长李彦宏在内部沟通会上表示,全部员工工资会进行普调,且预算超去年,年终奖可能还要多半个月,实习生也会涨工资。]]></digest>
<fileid>0</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><![CDATA[]]></play_url>
<player><![CDATA[]]></player>
<music_source>0</music_source>
<pic_num>0</pic_num>
<vid></vid>
<author><![CDATA[]]></author>
<recommendation><![CDATA[]]></recommendation>
<pic_urls></pic_urls>
<comment_topic_id>1264056910463057921</comment_topic_id>
<cover_235_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/oHIRnv852wvVLSSe2sgS9y626CQRGlenlwwBYrS6PaQLBKIExbuzesdQ5AI1FKP8scCBtxza2oUgJrD7Nl3ZFA/640?wxtype=jpeg&wxfrom=0]]></cover_235_1>
<cover_1_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/oHIRnv852wvVLSSe2sgS9y626CQRGlenVjDkbSvfZcnicJibXibD7xRxXRpY5N9RiaNzeFBJSWwJSlxcg5KEUGZdYQ/300?wxtype=jpeg&wxfrom=0]]></cover_1_1>
<appmsg_like_type>2</appmsg_like_type>
<video_width>0</video_width>
<video_height>0</video_height>
<is_pay_subscribe>0</is_pay_subscribe>
</item>
<item>
<itemshowtype>0</itemshowtype>
<title><![CDATA[35岁还能找到什么工作?]]></title> <url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzI1NjMxNzUyNA==&mid=2247492567&idx=2&sn=d7a7dfc017c9e680d1aada2ec6438b56&chksm=ea2a22ecdd5dabfa5bbe4f29b1adca298605318b669823f92403cb88d513f262aac8980abe6d&scene=0&xtrack=1#rd]]></url>
<shorturl><![CDATA[]]></shorturl>
<longurl><![CDATA[]]></longurl>
<pub_time>1584954006</pub_time>
<cover><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/oHIRnv852wvVLSSe2sgS9y626CQRGlenPFVIqmuMz1LJZcQSjcibcXadN5I3SKK4YG6MzTGA7nkLEia1uECVqZOQ/300?wxtype=jpeg&wxfrom=0]]></cover>
<tweetid></tweetid>
<digest><![CDATA[35岁危机,似乎是现在职场人挥之不去的噩梦,在自由职客平台上找到工作的人,有这样几种处理方式!]]></digest>
<fileid>0</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><![CDATA[]]></play_url>
<player><![CDATA[]]></player>
<music_source>0</music_source>
<pic_num>0</pic_num>
<vid></vid>
<author><![CDATA[]]></author>
<recommendation><![CDATA[]]></recommendation>
<pic_urls></pic_urls>
<comment_topic_id>1264056911184478208</comment_topic_id>
<cover_235_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/oHIRnv852wvVLSSe2sgS9y626CQRGlenPFVIqmuMz1LJZcQSjcibcXadN5I3SKK4YG6MzTGA7nkLEia1uECVqZOQ/300?wxtype=jpeg&wxfrom=0]]></cover_235_1>
<cover_1_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/oHIRnv852wvVLSSe2sgS9y626CQRGlenPFVIqmuMz1LJZcQSjcibcXadN5I3SKK4YG6MzTGA7nkLEia1uECVqZOQ/300?wxtype=jpeg&wxfrom=0]]></cover_1_1>
<appmsg_like_type>2</appmsg_like_type>
<video_width>0</video_width>
<video_height>0</video_height>
<is_pay_subscribe>0</is_pay_subscribe>
</item>
</category>
<publisher>
<username><![CDATA[gh_bd3eab772ede]]></username>
<nickname><![CDATA[自由职客]]></nickname>
</publisher>
<template_header></template_header>
<template_detail></template_detail>
<forbid_forward>0</forbid_forward>
</mmreader>
<thumburl><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/oHIRnv852wvVLSSe2sgS9y626CQRGlenlwwBYrS6PaQLBKIExbuzesdQ5AI1FKP8scCBtxza2oUgJrD7Nl3ZFA/640?wxtype=jpeg&wxfrom=0]]></thumburl>
</appmsg>
<fromusername><![CDATA[gh_bd3eab772ede]]></fromusername>
<appinfo>
<version></version>
<appname><![CDATA[自由职客]]></appname>
<isforceupdate>1</isforceupdate>
</appinfo>
</msg>
通过解析xml 即可得到微信公众号文章的详细信息。包含文章的标题,摘要,发布时间,封面,文章链接等内容,可以抓取文章的详细内容。
近期评论