phpcms v9关键词自动提取

phpcms v9关键词自动提取

<?php
defined('IN_PHPCMS') or exit('No permission resources.');

$number = intval($_GET['number']);
$title = $_POST['data'];
echo get_keywords($title, $number);

function get_keywords($title, $number = 3)
{
    $title = trim(strip_tags($title));
    if (empty($title)) {
        return '';
    }
    $url = 'http://116.196.101.207/get.php?source=' . urlencode($title) . '&param1=1&param2=1&json=1';
    $res = file_get_contents($url);
    $resArr = json_decode($res, true);
    $keywords = [];
    foreach ($resArr as $k => $v) {
        $keywords[] = $v['t'];
    }

    return implode(' ', $keywords);
}

把代码替换掉文件api/get_keywords.php就可以了

上一篇:Ubu18开机自启动


下一篇:ARM嵌入式学习笔记 - 制作最小Linux系统