共计 1738 个字符,预计需要花费 5 分钟才能阅读完成。
办法很简略,就是一段段截取就行,尽管很傻瓜,然而能实现就行。
<?php
// 设置 header
header("Content-type:application/json");
// 初始化 CURL
$ch = curl_init();
// 指标服务器地址
curl_setopt($ch, CURLOPT_URL, '公众号文章链接');
// 对认证证书起源的查看
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// 从证书中查看 SSL 加密算法是否存在
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
// 获取的信息以文件流的模式返回,而不是间接输入
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 发动申请
$result = curl_exec($ch);
$str_1 = substr($result,strripos($result,"profile_nickname")+18);
$str_2 = substr($str_1,0,strrpos($str_1,"profile_avatar")-52); // 公众号名称
$str_3 = substr($result,strripos($result,"微信号")+81);
$str_4 = substr($str_3,0,strrpos($str_3,"性能介绍")-163); // 公众号微信号
$str_5 = substr($str_3,strripos($str_3,"性能介绍")+84);
$str_6 = substr($str_5,0,strrpos($str_5,"profile_arrow_wrp")-172); // 公众号简介
$str_7 = substr($result,strripos($result,"twitter:title")+24);
$str_8 = substr($str_7,0,strrpos($str_7,"twitter:creator")-23); // 公众号文章题目
$str_9 = substr($result,strripos($result,"twitter:image")+24);
$str_10 = substr($str_9,0,strrpos($str_9,"twitter:title")-23); // 公众号文章封面图
$str_11 = substr($result,strripos($result,"twitter:description")+30);
$str_12 = substr($str_11,0,strrpos($str_11,"var testRdmUrl")-110);
$str_13 = substr($str_12,0,strrpos($str_12,">")-3); // 公众号文章摘要
$str_14 = substr($result,0,strrpos($result,"og:title")-27);
$str_15 = substr($str_14,strripos($str_14,"author")+17); // 公众号文章作者
$str_16 = substr($result,strripos($result,"div class="rich_media_content")+76);
$str_17 = substr($str_16,0,strrpos($str_16,"first_sceen__time")-75); // 公众号文章正文
$gzhmsg = array(
"公众号名称" => $str_2,
"微信号" => $str_4,
"公众号简介" => $str_6,
"文章题目" => $str_8,
"文章封面图" => $str_10,
"文章摘要" => $str_13,
"文章作者" => $str_15,
"注释" => $str_17
);
// 敞开申请
curl_close($ch);
// 输入 JSON
echo json_encode($gzhmsg,JSON_UNESCAPED_UNICODE);
?>
Author:TANKING
Date:2020-10-24
Web:http://www.likeyun.cn/
WeChat:face6009
正文完