PHP official account link extract title, cover, abstract, author, official account name, introduction, micro signal, text.

Time:2020-11-4

The method is very simple, that is to intercept a segment on the line, although very stupid, but can be implemented on the line.

<?php
//Set header 
header("Content-type:application/json");

//Initialize curl
$ch = curl_init();

//Target server address 
curl_ setopt($ch, CURLOPT_ URL, 'official account link');

//Check on the source of certification certificate
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//Check whether the SSL encryption algorithm exists from the certificate
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

//The information obtained is returned in the form of a file stream, rather than output directly
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//Initiate a request
$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 "; // official account name

$str_ 3 = substr ($result, stripos ($result, "micro signal") + 81);
$str_ 4 = substr($str_ 3,0,strrpos($str_ 3, function introduction) -163 // official account micro signal

$str_ 5 = substr($str_ 3,strripos($str_ 3, "function introduction") + 84);
$str_ 6 = substr($str_ 5,0,strrpos($str_ 5,"profile_ arrow_ WRP "" -172 "; // official account

$str_7 = substr($result,strripos($result,"twitter:title")+24);
$str_ 8 = substr($str_ 7,0,strrpos($str_ 7, " twitter:creator (-23); // official account title

$str_9 = substr($result,strripos($result,"twitter:image")+24);
$str_ 10 = substr($str_ 9,0,strrpos($str_ 9, " twitter:title (-23); // official account article cover

$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); // official account summary

$str_14 = substr($result,0,strrpos($result,"og:title")-27);
$str_ 15 = substr($str_ 14,strripos($str_ 14, "author") +17; // official account author

$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 "; // official account article body

$gzhmsg = array(
    The name of official account is > $str_ 2,
    "Micro signal" = > $str_ 4,
    "Official account number" = > $str_ 6,
    "Article title" = > $str_ 8,
    "Article cover map" = > $str_ 10,
    "Article summary" = > $str_ 13,
    "Article author" = > $str_ 15,
    "Body" = > $str_ Seventeen
);

//Close request
curl_close($ch);

//Output JSON
echo json_encode($gzhmsg,JSON_UNESCAPED_UNICODE);
?>

Author:TANKING
Date:2020-10-24
Web:http://www.likeyun.cn/
WeChat:face6009

Recommended Today

C # regular implementation of UBB parsing class code

The parsed code can pass XHTML   one   Strict verification;It includes title, link, font, alignment, picture, reference, list and other functions  Ubb.ReadMe.htm UBB code description title [H1] title I [/ H1] Title I [H2] Title II [/ H2] Title II [H1] Title III [/ H1] Title III [H4] Title IV [/ H4] Title IV […]