每日60秒读懂世界-文字版
青玄
2023年01月14日 22:21 / 0 评论 / 84 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2023年02月03日,已超过55天没有更新,若内容或图片失效,请留言反馈。

简介

这个接口数据是抓的一个知乎博主的
每天60秒读懂世界

1.png
接口是:https://www.zhihu.com/api/v4/columns/c_1261258401923026944/items
请求一次会给出10条数据,下标为0的是最新的那条,所以我们每次都去获取下标为0的那条就行

演示地址:被打了,焯!

代码

<?php
/*
 * @Descripttion: 
 * @version: 
 * @Author: lengxiaoyu
 * @Date: 2022-05-25 18:07:26
 * @LastEditTime: 2022-06-21 17:47:59
 */
header("Content-Type: text/html;charset=utf-8");
header("Content-Type: text/json; charset=$charset");
header("Access-Control-Allow-Origin:*");
header('Access-Control-Allow-Methods:GET');
header('Access-Control-Allow-Headers:x-requested-with, content-type');
require('phpQuery/phpQuery.php');
$a = file_get_contents("https://www.zhihu.com/api/v4/columns/c_1261258401923026944/items");
$data = json_decode(Unicode($a))->{"data"};
$html = $data[0]->{"url"};
phpQuery::newDocumentFile($html);
$p = pq('p')->text();
echo ($p);

// 缂栫爜杞崲
function Unicode($str)
{
    return preg_replace_callback(
        "#\\\u([0-9a-f]{4})#i",
        function ($r) {
            return iconv('UCS-2BE', 'UTF-8', pack('H4', $r[1]));
        },
        $str
    );
}
2

—— 评论区 ——

昵称
邮箱
网址
取消