基于搜狗微信搜索获取公众号文章的阅读量及点赞量

Posted 伯牙绝音

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于搜狗微信搜索获取公众号文章的阅读量及点赞量相关的知识,希望对你有一定的参考价值。

测试日期:2016/11/13

文章url样例

http://mp.weixin.qq.com/s?src=3&timestamp=1479004927&ver=1&signature=Z0OsvrGeP25z1f3laEdZjxCrLMvrwg3UfOxCFM1z5i-7qBOaiZDcL3lApbrzHiq5simLQc*n3KB-Ljy01WvBYFZB5D8S8Hcy5lgy6ejl0-HGr6QkqnRVIHMT6Xh5HzfIipcnWZyla-GJGQcxzMhqi5ab71F-adW9U8bzc9S0Kf0=

===================== 分割线 ====================

使用cURL直接访问公众号链接是无法得到文章的阅读量和点赞量的。

方法在sougou/index.js

http://res.wx.qq.com/mmbizwap/en_US/htmledition/js/sougou/index31aeff.js

其中有这个方法:

function o(){
var e="/mp/getcomment?";
for(var t in sg_data)e+=t+"="+encodeURIComponent(sg_data[t])+"&";
c({
url:e,
type:"get",
async:!0,
success:function(e){
var t=window.eval.call(window,"("+e+")"),n=t.base_resp&&t.base_resp.ret;
if(0==n){
var o=document.createDocumentFragment(),i=t.comment;
i&&i.length?l(i,o,"elected"):document.getElementById("sg_cmt_area").style.display="none",
document.getElementById("sg_readNum3").innerHTML=parseInt(t.read_num)>=1e5?"100000+":t.read_num,
document.getElementById("sg_likeNum3").innerHTML=t.like_num;
}else document.getElementById("sg_cmt_area").style.display="none",document.getElementById("js_sg_bar").style.display="none";
}
});
}
sg_data,就是文章url路径的参数
window.sg_data={
            src:"3",
            ver:"1",
            timestamp:"1479004927",
            signature:"Z0OsvrGeP25z1f3laEdZjxCrLMvrwg3UfOxCFM1z5i-7qBOaiZDcL3lApbrzHiq5simLQc*n3KB-Ljy01WvBYFZB5D8S8Hcy5lgy6ejl0-HGr6QkqnRVIHMT6Xh5HzfIipcnWZyla-GJGQcxzMhqi5ab71F-adW9U8bzc9S0Kf0="
        }

那么获取点赞量和阅读量的url(api+参数)为:
http://mp.weixin.qq.com/mp/getcomment?src=3&timestamp=1479004927&ver=1&signature=Z0OsvrGeP25z1f3laEdZjxCrLMvrwg3UfOxCFM1z5i-7qBOaiZDcL3lApbrzHiq5simLQc*n3KB-Ljy01WvBYFZB5D8S8Hcy5lgy6ejl0-HGr6QkqnRVIHMT6Xh5HzfIipcnWZyla-GJGQcxzMhqi5ab71F-adW9U8bzc9S0Kf0=

注意:如果文章的阅读量超过了10W,那么返回的数据是“100001”。

json格式的返回值,结果如下:

 

{
    "base_resp": {
        "ret": 0,
        "errmsg": "ok"
    },
    "comment": [
        {
            "id": 19,
            "my_id": 3,
            "nick_name": "A 郭小胖",
            "logo_url": "http://wx.qlogo.cn/mmopen/vi_24/gia9TticbVQGaDRiamDDFfk5JtQWnZ4vbnYdg4IATTvibQZiaUEsGRHAnDX7ZCb51f0IFvd8aMsR0KFo/132",
            "content": "我喜欢有特长的!/白眼",
            "create_time": 1478872129,
            "content_id": "10229371626617569283",
            "like_id": 10001,
            "like_num": 203,
            "like_status": 0,
            "reply": {
                "reply_list": []
            }
        },
        {
            "id": 21,
            "my_id": 43,
            "nick_name": "[美][爱心][爱心]",
            "logo_url": "http://wx.qlogo.cn/mmopen/vi_24/gia9TticbVQGZ01UUibZgg2OssHzwSNJqffzEOTCl0vmtxKQ4b0x9mY784kLpgZsQyXyicbtRGKg3Xo/132",
            "content": "我也喜欢持久型的。",
            "create_time": 1478872369,
            "content_id": "7482069089624522795",
            "like_id": 10003,
            "like_num": 130,
            "like_status": 0,
            "reply": {
                "reply_list": []
            }
        },
        {
            "id": 18,
            "my_id": 13,
            "nick_name": "原子蚂蚁..",
            "logo_url": "http://wx.qlogo.cn/mmopen/vi_24/gia9TticbVQGbecBueU9feLhFZPA3JRZmqZ5buK4IuTUk0Ytz4PPWj4UoZxgLdzia1aHjW5LTO794g/132",
            "content": "我喜欢频繁型的…致敬Top10/害羞",
            "create_time": 1478871988,
            "content_id": "9020778575531343885",
            "like_id": 10004,
            "like_num": 109,
            "like_status": 0,
            "reply": {
                "reply_list": []
            }
        },
        {
            "id": 14,
            "my_id": 2,
            "nick_name": "冷暖自知’",
            "logo_url": "http://wx.qlogo.cn/mmopen/vi_24/hqDXUD6csUicTvoDutwqIGI04JQHUYlZB2L80GNUHC8fXsGSQ0jYs0FhX8icFn8PmdD0mjkxUia8dY/132",
            "content": "TOP6  你就不怀疑是你老公放的煤气?",
            "create_time": 1478871691,
            "content_id": "3058943487090098178",
            "like_id": 10007,
            "like_num": 50,
            "like_status": 0,
            "reply": {
                "reply_list": []
            }
        },
        {
            "id": 43,
            "my_id": 103,
            "nick_name": "··",
            "logo_url": "http://wx.qlogo.cn/mmopen/vi_24/hqDXUD6csUicMtjOpGPKgibknfic4atcodYfzy2QUoiaEcn1GbuegEhVlVDeEWIUkqovZlRhMk40wwQ/132",
            "content": "坐车一个小时叫异地???我这堵车都堵一个小时!",
            "create_time": 1478881088,
            "content_id": "1278630296803082343",
            "like_id": 10009,
            "like_num": 40,
            "like_status": 0,
            "reply": {
                "reply_list": []
            }
        },
        {
            "id": 1,
            "my_id": 7,
            "nick_name": "风一样的男子",
            "logo_url": "http://wx.qlogo.cn/mmopen/vi_24/PiajxSqBRaEKzFLlsHpUQLqYkXLAjKzDA52UrdMSYvWktF3iaqdxIAJuGQFuW53KwmKZnoc70g2L0/132",
            "content": "今天才发现,自己是千手观音/撇嘴",
            "create_time": 1478871139,
            "content_id": "258712444610805767",
            "like_id": 10005,
            "like_num": 33,
            "like_status": 0,
            "reply": {
                "reply_list": [
                    {
                        "content": "手还在么?",
                        "uin": 2398003040,
                        "create_time": 1478872478,
                        "reply_id": 1,
                        "to_uin": 60236185,
                        "reply_like_num": 14
                    }
                ]
            }
        },
        {
            "id": 16,
            "my_id": 6,
            "nick_name": "Money",
            "logo_url": "http://wx.qlogo.cn/mmopen/vi_24/8qeYwBfUUNntvc2cic5icH5Ziclib0QQufcHRIzlhg5FXW31LQY8F9MW4WR88ytepGQfWn9oeXqgC7s/132",
            "content": "今天单着的忙着脱单双着忙着下单,都忘了来点赞",
            "create_time": 1478871810,
            "content_id": "8697750726534758406",
            "like_id": 10002,
            "like_num": 31,
            "like_status": 0,
            "reply": {
                "reply_list": []
            }
        },
        {
            "id": 23,
            "my_id": 20,
            "nick_name": "天未亮?心微凉",
            "logo_url": "http://wx.qlogo.cn/mmopen/vi_24/gia9TticbVQGaibgzRSoZ26EYMKeEruBVKm7m7K8OXgJ32xlfJqvh08AVJUJZIwO7LStFjIPqzjA2A/132",
            "content": "第一个你小妹知道的太多了",
            "create_time": 1478872394,
            "content_id": "12699376059775189012",
            "like_id": 10006,
            "like_num": 17,
            "like_status": 0,
            "reply": {
                "reply_list": []
            }
        },
        {
            "id": 39,
            "my_id": 22,
            "nick_name": "香蕉你个巴拉~",
            "logo_url": "http://wx.qlogo.cn/mmopen/vi_24/6oHnTRVDvkVZwTWrXMEEOtKicQ4mOIYZ77XCnp4y87ibsJibQuILJZCXicwGmF7ovVYaMWZ03fTlZibQ/132",
            "content": "顶四楼的千手观音/憨笑",
            "create_time": 1478878822,
            "content_id": "7289469690781368342",
            "like_id": 10008,
            "like_num": 10,
            "like_status": 0,
            "reply": {
                "reply_list": []
            }
        },
        {
            "id": 35,
            "my_id": 17,
            "nick_name": "异世邪君",
            "logo_url": "http://wx.qlogo.cn/mmopen/vi_24/gia9TticbVQGYtFvzLhI0sMNMGHZIMeiazn8icS3N4wfRCp4r3g7pBbLuYFMUv4lpZCoLuYhrZGNRyI/132",
            "content": "TOP3真的戳中我笑点了,眼泪都笑出来了。",
            "create_time": 1478876379,
            "content_id": "5503949149000695825",
            "like_id": 10010,
            "like_num": 8,
            "like_status": 0,
            "reply": {
                "reply_list": []
            }
        }
    ],
    "elected_comment_total_cnt": 10,
    "read_num": 100001,
    "like_num": 686
}

 

不过不知道什么时候这个接口就挂掉了,望君珍重.....














以上是关于基于搜狗微信搜索获取公众号文章的阅读量及点赞量的主要内容,如果未能解决你的问题,请参考以下文章

python爬微信公众号前10篇历史文章

如何抓取微信所有公众号最新文章

python爬搜狗微信获取指定微信公众号的文章

java 爬取微信公众号文章 - 搜狗微信搜索

python 微信公众号文章抓取阅读数和点赞数

怎样在电脑上查看别人的公众帐号