API说明

聚合热搜热榜PHP接口API源码,本源码接口均抓取采集各大官网数据。

PHP环境为5.6或以上,解压压缩包里面的hotlist.php文件到网站目录

然后输入参数输入?type

参数内容;

zhihu(知乎热榜) weibo(微博热搜) baidu(百度热点) history(历史上的今天) bilihot(哔哩哔哩热搜) biliall(哔哩哔哩全站日榜) sspai(少数派头条) douyin(抖音热搜) CSDN(CSDN头条榜) 使用方法;

访问你的域名地址/hotlist.php?type=

?type=(输入参数才能显示内容)

示例;访问你的域名地址/hotlist.php?type=zhihu

API源码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

<?php

header("Access-Control-Allow-Origin:*");

header("Content-type:application/json; charset=utf-8");

date_default_timezone_set("Asia/Shanghai");

class Api

{

  // 少数派 热榜

  public function sspai()

  {

    $jsonRes = json_decode($this->Curl('https://sspai.com/api/v1/article/tag/page/get?limit=100000&tag=%E7%83%AD%E9%97%A8%E6%96%87%E7%AB%A0', null, null, "https://sspai.com"), true);

    $tempArr = [];

    foreach ($jsonRes['data'as $k => $v) {

      array_push($tempArr, [

        'index' => $k +1,

        'title' => $v['title'],

        'createdAt' => date('Y-m-d'$v['released_time']),

        'other' => $v['author']['nickname'],

        'like_count' => $v['like_count'],

        'comment_count' => $v['comment_count'],

        'url' => 'https://sspai.com/post/'.$v['id'],

        'mobilUrl' => 'https://sspai.com/post/'.$v['id']

      ]);

    }

    return [

      'success' => true,

      'title' => '少数派',

      'subtitle' => '热榜',

      'update_time' => date('Y-m-d h:i:s', time()),

      'data' => $tempArr

    ];

  }

  

  // CSDN 头条榜

  public function csdn()

  {

    $_resHtml $this->Curl('https://www.csdn.net', null, "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1""https://www.csdn.net");

    preg_match('/window.__INITIAL_STATE__=(.*?);<\/script>/'$_resHtml$_resHtmlArr);

    $jsonRes = json_decode($_resHtmlArr[1],true);

    $tempArr = [];

    //头条

    foreach ($jsonRes['pageData']['data']['Headimg'as $k => $v) {

      array_push($tempArr, [

        'index' => $k +1,

        'title' => $v['title'],

        'url' => $v['url'],

        'mobilUrl' => $v['url']

      ]);

    }

    //头条1

    foreach ($jsonRes['pageData']['data']['www-Headlines'as $k => $v) {

      array_push($tempArr, [

        'index' => $k +17,

        'title' => $v['title'],

        'url' => $v['url'],

        'mobilUrl' => $v['url']

      ]);

    }

    //头条2

    foreach ($jsonRes['pageData']['data']['www-headhot'as $k => $v) {

      array_push($tempArr, [

        'index' => $k +48,

        'title' => $v['title'],

        'url' => $v['url'],

        'mobilUrl' => $v['url']

      ]);

    }

    return [

      'success' => true,

      'title' => 'CSDN',

      'subtitle' => '头条榜',

      'update_time' => date('Y-m-d h:i:s', time()),

      'data' => $tempArr

    ];

  }

  

  //百度百科  历史上的今天

  public function history()

  {

    $month=date('m',time() );

    $day=date('d',time() );

    //当前年月日

    $today date('Y年m月d日');

    //获取接口数据

    $jsonRes = json_decode($this->Curl('https://baike.baidu.com/cms/home/eventsOnHistory/'.$month.'.json', null, null, "https://baike.baidu.com"), true);

    $tempArr = [];

    //统计当日总数

    $countnum count($jsonRes[$month][$month.$day])-1;

    foreach ($jsonRes[$month][$month.$dayas $k => $v) {

      array_push($tempArr, [

        'index' => $k +1,

        'title' => $v['year'].'年-'.strip_tags($v['title']),

        'url' => 'https://www.douyin.com/search/'.urlencode($v['title']),

        'mobilUrl' => 'https://www.douyin.com/search/'.urlencode($v['title'])

      ]);

    }

    return [

      'success' => true,

      'title' => '百度百科',

      'subtitle' => '历史上的今天',

      'update_time' => date('Y-m-d h:i:s', time()),

      'data' => $tempArr

    ];

  }

  

  // 抖音 热搜榜

  public function douyin()

  {

    $jsonRes = json_decode($this->Curl('https://www.iesdouyin.com/web/api/v2/hotsearch/billboard/word/', null, null, "https://www.douyin.com"), true);

    $tempArr = [];

    foreach ($jsonRes['word_list'as $k => $v) {

      array_push($tempArr, [

        'index' => $k +1,

        'title' => $v['word'],

        'hot' => round($v['hot_value']/10000,1).'万',

        'url' => 'https://www.douyin.com/search/'.urlencode($v['word']),

        'mobilUrl' => 'https://www.douyin.com/search/'.urlencode($v['word'])

      ]);

    }

    return [

      'success' => true,

      'title' => '抖音',

      'subtitle' => '热搜榜',

      'update_time' => date('Y-m-d h:i:s', time()),

      'data' => $tempArr

    ];

  }

  // 哔哩哔哩 全站日榜

  public function bilibili_rankall()

  {

    $jsonRes = json_decode($this->Curl('https://api.bilibili.com/x/web-interface/ranking/v2?rid=0&type=all', null, null, "https://www.bilibili.com"), true);

    $tempArr = [];

    foreach ($jsonRes['data']['list'as $k => $v) {

      array_push($tempArr, [

        'index' => $k +1,

        'title' => $v['title'],

        'pic' => $v['pic'],

        'desc' => $v['desc'],

        'hot' => round($v['stat']['view']/10000,1).'万',

        'url' => $v['short_link'],

        'mobilUrl' => $v['short_link']

      ]);

    }

    return [

      'success' => true,

      'title' => '哔哩哔哩',

      'subtitle' => '全站日榜',

      'update_time' => date('Y-m-d h:i:s', time()),

      'data' => $tempArr

    ];

  }

  // 哔哩哔哩 热搜榜

  public function bilibili_hot()

  {

    $jsonRes = json_decode($this->Curl('https://app.bilibili.com/x/v2/search/trending/ranking', null, null, "https://www.bilibili.com"), true);

    $tempArr = [];

    //return $jsonRes;

    foreach ($jsonRes['data']['list'as $k => $v) {

      array_push($tempArr, [

        'index' => $v['position'],

        'title' => $v['keyword'],

        'url' => 'https://search.bilibili.com/all?keyword='.$v['keyword'].'&order=click',

        'mobilUrl' => 'https://search.bilibili.com/all?keyword='.$v['keyword'].'&order=click'

      ]);

    }

    return [

      'success' => true,

      'title' => '哔哩哔哩',

      'subtitle' => '热搜榜',

      'update_time' => date('Y-m-d h:i:s', time()),

      'data' => $tempArr

    ];

  }

  

  // 知乎热榜  热度

  public function zhihuHot()

  {

    $jsonRes = json_decode($this->Curl('https://www.zhihu.com/api/v3/feed/topstory/hot-lists/total?limit=50&desktop=true', null, null, "https://www.zhihu.com"), true);

    $tempArr = [];

    foreach ($jsonRes['data'as $k => $v) {

      preg_match('/\d+/',  $v['detail_text'], $hot);

      array_push($tempArr, [

        'index' => $k + 1,

        'title' => $v['target']['title'],

        'hot' => $hot[0].'万',

        'url' => 'https://www.zhihu.com/question/'.urlencode($v['target']['id']),

        'mobilUrl' => 'https://www.zhihu.com/question/'.urlencode($v['target']['id'])

      ]);

    }

    return [

      'success' => true,

      'title' => '知乎热榜',

      'subtitle' => '热度',

      'update_time' => date('Y-m-d h:i:s', time()),

      'data' => $tempArr

    ];

  }

  // 微博 热搜榜

  public function wbresou()

  {

    $_md5 = md5(time());

    $cookie "Cookie: {$_md5}:FG=1";

    $jsonRes = json_decode($this->Curl('https://weibo.com/ajax/side/hotSearch', null, $cookie"https://s.weibo.com"), true);

    $tempArr = [];

    foreach ($jsonRes['data']['realtime'as $k => $v) {

      array_push($tempArr, [

        'index' => $k + 1,

        'title' => $v['note'],

        'hot' => round($v['num']/10000,1).'万',

        'url' => "https://s.weibo.com/weibo?q=".$v['note']."&Refer=index",

        'mobilUrl' => "https://s.weibo.com/weibo?q=".$v['note']."&Refer=index"

      ]);

    }

    return [

      'success' => true,

      'title' => '微博',

      'subtitle' => '热搜榜',

      'update_time' => date('Y-m-d h:i:s', time()),

      'data' => $tempArr

    ];

  }

  // 百度热点 指数

  public function baiduredian()

  {

    $_resHtml str_replace(["\n""\r"" "], ''$this->Curl('https://top.baidu.com/board?tab=realtime', null));

    preg_match('/<!--s-data:(.*?)-->/'$_resHtml$_resHtmlArr);

    $jsonRes = json_decode($_resHtmlArr[1], true);

    //return $jsonRes;

    $tempArr = [];

    foreach ($jsonRes['data']['cards'as $v) {

      foreach ($v['content'as $k => $_v) {

        array_push($tempArr, [

          'index' => $k + 1,

          'title' => $_v['word'],

          'desc' => $_v['desc'],

          'pic' => $_v['img'],

          'url' => $_v['url'],

          'hot' => round($_v['hotScore']/10000,1).'万',

          'mobilUrl' => $_v['appUrl']

        ]);

      }

    }

    return [

      'success' => true,

      'title' => '百度热点',

      'subtitle' => '指数',

      'update_time' => date('Y-m-d h:i:s', time()),

      'data' => $tempArr

    ];

  }

  private function Curl($url$header = [

    "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",

    "Accept-Encoding: gzip, deflate, br",

    "Accept-Language: zh-CN,zh;q=0.9",

    "Connection: keep-alive",

    "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1"

  ], $cookie = null, $refer 'https://www.baidu.com')

  {

    $ip = rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255);

    $header[] = "CLIENT-IP:" $ip;

    $header[] = "X-FORWARDED-FOR:" $ip;

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url); //设置传输的 url

    curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //发送 http 报头

    curl_setopt($ch, CURLOPT_COOKIE, $cookie); //设置Cookie

    curl_setopt($ch, CURLOPT_REFERER,  $refer); //设置Referer

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); // 解码压缩文件

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // 对认证证书来源的检查

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // 从证书中检查SSL加密算法是否存在

    curl_setopt($ch, CURLOPT_TIMEOUT, 5); // 设置超时限制防止死循环

    $output = curl_exec($ch);

    curl_close($ch);

    return $output;

  }

}

$_type = isset($_GET['type']) ? $_GET['type'] : '';

$API new Api;

switch ($_type) {

  case 'baidu':

    $_res $API->baiduredian();

    break;

  case 'zhihu':

    $_res $API->zhihuHot();

    break;

  case 'weibo':

    $_res $API->wbresou();

    break;

  case 'bilihot':

    $_res $API->bilibili_hot();

    break;

  case 'biliall':

    $_res $API->bilibili_rankall();

    break;

  case 'douyin':

    $_res $API->douyin();

    break;

  case 'history':

    $_res $API->history();

    break;

  case 'csdn':

    $_res $API->csdn();

    break;

  case 'sspai':

    $_res $API->sspai();

    break;

  default:

    $_res = ['success' => false, 'message' => '参数不完整'];

    break;

}

$_res['copyright'] = '聚合热搜榜';

exit(json_encode($_res,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT));

?>

聚合热搜热榜PHP接口API源码相关推荐

  1. 2023最新聚合热搜热榜PHP接口API源码

    聚合热搜热榜PHP接口API源码,本源码接口均抓取采集各大官网数据. PHP环境为5.6或以上,解压压缩包里面的hotlist.php文件到网站目录 然后输入参数输入?type 参数内容: zhihu ...

  2. 获取Favicon.ico网站图标接口api源码

    介绍: 获取Favicon.ico网站图标接口 favicon.ico一般用于作为缩略的网站标志,它显示位于浏览器的地址栏或者在标签上用于显示网站的logo, 目前主要的浏览器都支持favicon.i ...

  3. 网址拦截查询接口API源码

    获取的是拦截官网的数据,可以查询QQ和微信的是否被拦截,此源码为网址拦截接口API * 提交方式GET* 请求参数:domain(域名url)* 示例:ymjc.php?domain=azpay.cn ...

  4. 南网优惠电费接口API源码

    电费充值接口 1.添加充值卡 网关URL:https://router.wikeyun.cn/rest/Power/addCard 参数名 类型 必填 参数说明 store_id 字符串 是 店铺ID ...

  5. 卡卷特权接口API源码

    卡券.直充接口 1.获取卡券特权数据(直充.卡券) 网关URL:https://router.wikeyun.cn/rest/Quanyi/privilege 参数名 类型 必填 参数说明 id in ...

  6. 股票交易查询接口api源码分享

    股票交易查询接口是一个股票分析的工具,投资折可以通过这个接口在股票的买卖过程中自己判断是否要做空,简单来说股票交易查询接口就用来判断股价上涨或者下跌以及投资亏损的分析工具! 那么在本质上来说股票交易查 ...

  7. 南方电信电网接口API源码

    1.3 业务流程 1.打开控制台 https://control.wikeyun.cn/ 进行注册账号 2.点击添加店铺,只勾选CMS即可,或者店铺ID保存. 3.联系客服申请 app_key与app ...

  8. 直充卡券话费接口API源码分享

    微客云直充卡券话费 开发团队致力于此模块生命力至少3-5年 此模块以资源种类,官方直联接口为优势,不纯以软件更新为主,力争版本精准化服务用户 单独直充卡券话费系统,直接完成对各种消费场景的流量变现,更 ...

  9. 三网话费接口API源码分享

    二.话费充值接口 1.充值请求下单(post 表单提交) 网关URL:https://router.wikeyun.cn/rest/Recharge/pushOrder 参数名 类型 必填 参数说明 ...

最新文章

  1. 关于手机系统信息的总结
  2. Javascript迄今为止添加了前导零
  3. 维度及长度均可任意变形的动态数组
  4. 洛谷1967货车运输
  5. Java调优:Mybaitis的缓存优化
  6. JS面向对象的程序设计之创建对象_工厂模式,构造函数模式,原型模式-1
  7. 徐直军 华为没有鸿蒙,3亿只剩1亿?华为高管改口,推出鸿蒙到底有啥苦衷?
  8. OD使用教程10 - 调试篇10|解密系列
  9. php ckeditor图片上传
  10. 通力法评 | 资管新规系列一:对公募基金管理公司的影响
  11. React 集成jsoneditor后,password格式保护json数据的敏感信息
  12. 无线路由器的DNS服务器怎么设置,无线路由器DNS的设置方法
  13. 关于盒子背景图片布局
  14. 《愿你历尽千帆 归来仍是少年》 读后
  15. 基于ThinkPHP6+Layui后台开发框架
  16. Android开发——适配终结者AutoLayout
  17. axp202电源管理
  18. HihoCoder 1246:王胖浩与环
  19. 集合_Collection
  20. 微信小程序开发:自定义组件-behaviors

热门文章

  1. js第7章DOM案例:获取操作的元素、元素内容操作、元素属性操作、classList的使用、获取节点、节点追加、删除节点和节点属性
  2. 大数据Hadoop教程-学习笔记02【Apache Hadoop、HDFS】
  3. 基于Android的图片分享软件
  4. 4年估值140亿的元气森林 内忧外患的壁垒困境
  5. 聚簇索引(聚集索引)
  6. 小希的迷宫——HDU1272
  7. 【文章阅读】BN(2015)理解Batch Normalization批标准化
  8. @Transient
  9. Intermediate-Data-Visualization-with-Seaborn
  10. GIT撤销修改 restore