方法很簡單,就是一段段截取就行,雖然很傻瓜,可是能實現就行。php
<?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算法