Hongmu Notes
Home Program Notes Empire cms collects article keywords and generates them
Program Notes Empire cms

Empire cms collects article keywords and generates them

Empire cms collects article keywords and generates them

The codes are all simple and trivial. As long as there is an API for word segmentation, everything will not be a problem!

PHP code presented:


<?php
echo '<meta http-equiv="refresh" content="2"/>';
require('../e/class/connect.php');        //引入数据库配置文件和公共函数文件
require('../e/class/db_sql.php');        //引入数据库操作文件
$link=db_connect();                //连接MYSQL
$empire=new mysqlquery();        //声明数据库操作类

//翻页配置
$file = "keyword.txt";
$num = 100;
if(file_exists($file)){
    $page_num = file_get_contents($file);
}else{
    $page_num = 0;
}
$page_id = $page_num*$num;

$sql=$empire->query("select id,keyboard,title from {$dbtbpre}ecms_news  order by id limit {$page_id},{$num}");        //查询新闻表最新10条记录
while($r=$empire->fetch($sql))        //循环获取查询记录
{
    $api = "分词api" . urlencode($r['title']);
    $keyword = json_decode(file_get_contents($api),true);
    $keywords = ''; //变量赋值为空
    //用foreach 遍历下二维数组
    foreach($keyword as $vals){
    $keywords.=$vals.',';
    }
    // 使用 rtrim() 函数从字符串右端删除字符:
    $keywords = rtrim($keywords, ',');
    echo "<pre>标题:" . $r['title']."<br>id:". $r['id']."<br>分词结果:".$keywords;
    // var_dump($keywords);
    $empire->query1("UPDATE `{$dbtbpre}ecms_news` SET `keyboard` = '{$keywords}' WHERE `id` = {$r[id]};");
}
$page_num++;
file_put_contents($file,$page_num);
db_close();                        //关闭MYSQL链接
$empire=null;                        //注消操作类变量
?>

Note that you need to find the word segmentation API by yourself. Of course, you can also contact me for commercial rental!

Effect:


标题:金盾驾校怎么样(合肥金武联驾校怎么样)
id:13001
分词结果:驾校,金盾,金武联,合肥

标题:金盛怎么样(金盛贵金属怎么样)
id:13002
分词结果:金盛,贵金属

标题:金石投资怎么样(香港金石投资集团)
id:13003
分词结果:金石,投资,香港,集团

标题:金碟怎么样(金碟怎么样建帐)
id:13004
分词结果:金碟,建帐

标题:金盏花怎么样(科颜氏金盏花怎么样)
id:13005
分词结果:金盏花,科颜氏

标题:金石滩怎么样(金石滩实验小学怎么样)
id:13006
分词结果:金石滩,小学,实验

标题:金石为什么(成语金石为什么)
id:13007
分词结果:金石,成语

标题:金种子酒怎么样(金种子酒股票前景怎么样)
id:13008
分词结果:种子,前景,股票

标题:金科房子怎么样(万科和金科房子的质量怎么样)
id:13009
分词结果:金科,房子,万科,质量

标题:金科地产待遇怎么样(金科地产员工待遇怎么样)
id:13010
分词结果:金科,待遇,地产,员工

标题:金石资源怎么样(金石资源潜力巨大)
id:13011
分词结果:金石,资源,潜力

标题:金科世界城怎么样(沣西金科世界城怎么样)
id:13012
分词结果:金科,世界

标题:iphonese怎么样(iphonese怎么样)
id:21001
分词结果:iphonese

标题:iphone为什么会黑屏(iphone为什么会黑屏然后里面有声音)
id:21002
分词结果:黑屏,iphone,声音

标题:iphone为什么充不进电(为什么iphone充不进去电)
id:21003
分词结果:iphone,充不进,充不

标题:iphone为什么内存不足(为什么iphone突然内存不足)
id:21004
分词结果:iphone,内存不足

标题:iphone为什么更新不了软件(iphone更新不了软件怎么办)
id:21005
分词结果:iphone,软件,更新

标题:iphone为什么连不上wifi(iPhone为什么连不上耳机)
id:21006
分词结果:连不上,iphone,wifi,iPhone,耳机

标题:iphone怎么样(iphone怎么样算激活)
id:21007
分词结果:iphone,激活

标题:iphone手机怎么样(iphone是什么牌子的手机)
id:21008
分词结果:iphone,手机,牌子

标题:iphone恢复出厂设置会怎么样(iphone恢复出厂设置会怎么样 可以重新备份吗)
id:21009
分词结果:iphone,出厂,设置,恢复,备份

标题:ipod怎么样(ipod怎么样连接功放)
id:21010
分词结果:ipod,功放,连接

标题:ipo为什么排队(为什么ipo价格都比较低)
id:21011
分词结果:ipo,排队,价格

标题:ipo重启为什么(2014年ipo市场重启)
id:21012
分词结果:ipo,重启,2014,市场
微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Empire CMS database statement & SQL statement format

Empire CMS database statement & SQL statement format Program Notes Empire cms

Introduction to Imperial CMS extended SQL program writing, basic examples of Imperial CMS database statements & SQL statement formats: Note: The following examples are based on placing PHP files in the system root directory. Example 1: Connect to MYSQL program. (a.php)<?php require('e/class/connect.php'); //Introduce database configuration files and public function files requ…
👁 351
Empire CMS obtains the system COOKIE variable function getcvar()

Empire CMS obtains the system COOKIE variable function getcvar() Program Notes Empire cms

Get the system COOKIE variable function syntax: getcvar($var,$ecms) Description: $var: is the variable name $ecms: 0 is to set the foreground COOKIE variable, 1 is to set the background COOKIE variable. This parameter can be omitted and defaults to 0. Usage example: getcvar('mlusername'), get the user name of the front-end login member getcvar('loginu...
👁 296
Empire CMS smart label call field collection

Empire CMS smart label call field collection Program Notes Empire cms

Collect and classify all fields that support smart tag calls into Empire CMS smart tags: [e:loop={column ID/topic ID, number of items displayed, operation type, only display pictures with titles, additional SQL conditions, display sorting}] Template code content [/e:loop] Calling time: <?=date('m-d',$bqr[newstime])?> <?=dat…
👁 3749

Recommended reading

(Adaptive mobile version) Health products and health product website template download 0996

(Adaptive mobile version) Health products and health product website template download 0996 Practical Collection pbootcms Template

A PbootCMS website template designed for health and wellness products, compatible with both PC and WAP devices. Its professional and health-focused design makes it ideal for health product brands to showcase their product ranges, share health-related knowledge, and tell their brand stories. This template helps health product companies attract online customers and enhance their brand image. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn...
👁 59
(Adaptive Mobile Version) Business Service Website Template – Download Commercial Management Website Source Code: 0997

(Adaptive Mobile Version) Business Service Website Template – Download Commercial Management Website Source Code: 0997 Practical Collection pbootcms Template

A PbootCMS website template designed for business services and corporate management, compatible with both PC and WAP devices. Its professional and sophisticated design makes it ideal for business consulting firms and management service providers to showcase their services and success stories. This template helps service providers attract corporate clients online and expand their business reach. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn...
👁 77
(Adaptive mobile version) Certificate query system website template 0998

(Adaptive mobile version) Certificate query system website template 0998 Practical Collection pbootcms Template

A Certificate Verification System – PbootCMS website template, compatible with both PC and WAP devices. Featuring a clean and user-friendly design, it provides users with convenient certificate authenticity verification and information validation services. Ideal for educational institutions, industry associations, or enterprises looking to build an official certificate inquiry platform. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn...
👁 57
Resource website typecho001 template

Resource website typecho001 template Program Notes Typecho

typecho001 template template please do not modify the folder name of this template. The folder name is: typecho001 1.4 Fix the js output problem on the article page 1.3 Fix the error prompt when the plug-in is not installed Optimize the list page code output 1.2 Fix the comment function and add a custom homepage title 1.1 Fix the comment reply asymmetry function Add a separate title setting function on the homepage Add the website favicon.ico icon Add one...
👁 199
What does loose or watery stool mean in Traditional Chinese Medicine?

What does loose or watery stool mean in Traditional Chinese Medicine? Hobbies Traditional Chinese Medicine Terminology

In traditional Chinese medicine (TCM) practice, loose stools typically refer to stools that are more watery than usual or even contain liquid discharge; this condition is also known as diarrhea. It often occurs in cases associated with TCM pathological mechanisms such as Spleen and Stomach Deficiency-Cold, dyspepsia, or excessive dampness. Spleen and Stomach Deficiency-Cold refers to a deficiency of Yang energy in the body, which leads to impaired function of the digestive system and consequently affects the formation of stools. Dyspepsia denotes a weakened digestive and absorptive capacity of the gastrointestinal tract, resulting in incomplete digestion and absorption of food, which in turn affects stool consistency...
👁 162