[JavaScript] 纯文本查看 复制代码 // <meta property="og:url" content="http://mp.weixin.qq.com/s?__biz=MzIxNDA0MTExMg==&mid=2652150124&idx=1&sn=8db5fe8374a0b7d0dfb5d68195a220c7&chksm=8c4dae1bbb3a270dadfdbd7048a17ec3a0bb003b0a4f4321ff2a30db9be6c825f411e7521136#rd">
//https://mp.weixin.qq.com/s/mMth4SLsT6BKJbwmCjHsQQ //文章地址
let request = require("request");
var cheerio = require('cheerio');
var { getQueryVariable } = require('../util/tool');
let countUrl = "https://mp.weixin.qq.com/s/YtK86SnX8COpX4xtMAMdnw";
let coverUrl = "";//封面
let __biz = "";//公众号id
request({
url: countUrl,
method: 'GET',
headers: {
'User-Agent': `Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1`,
'Accept-Language': `zh-CN,zh;q=0.9`,
},
}, (err, res, body)=> {
// console.log(body)
var $ = cheerio.load(body);
$("meta").each((index, element)=>{
let property = $(element).attr('property')
// console.log(property)
switch (property) {
case "og:image":
coverUrl = $(element).attr('content');
break;
case "og:url":
__biz = getQueryVariable($(element).attr('content'),"__biz");
break;
}
})
let js_name = $("#js_name").text().trim()
console.log(`公众号名称 : ${js_name}
公众号id : ${__biz}
封面 : ${coverUrl}
公众号主页 : https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=${__biz}
`)
})
|