网易首页 > 网易号 > 正文 申请入驻

PHP24小时自动更新采集标题

0
分享至

大家都知道网站需要时效性强的内容,那么泛目录更注重这点,内容时效性强且及时更新就是泛目录首先要解决的问题。今天,错误博客(cuowu.com)分享的内容为《PHP24小时自动更新采集标题》。希望对大家有所帮助。

一、自动采集原理

自动采集用的是三个php文件,每个文章均放一个header("refresh;url"),A里面放B,B里面放C,C里面放A,开始只需要运行A,那么B过一定时间就会运行一次,B运行时会运行C一次,C运行时会回到A,周而复始,这样子就可以让三个php文件24小时内自动采集了。

header("refresh:600;url=./cuowucom_biaotiA.php");
header("refresh:6;url=./cuowucom_biaotiB.php");
header("refresh:26;url=./cuowucom_biaoti.php");

如下图所示为采集到的标题:

二、PHP采集标题到txt

泛目录程序中需要调用一些时效性强的标题,采用PHP程序实现自动采集并存放到txt中,会很方便。至少比以前介绍的利用宝塔来定时访问要好很多,因为宝塔定时访问可能会增加不少问题出现概率。三个PHP采集中国新闻网的源码如下:

cuowu_biaoti.php


$txtnames ="cuowucom/biaoti/cuowucom-biaoti.txt";
header("refresh:6;url=./cuowucom_biaotiA.php");
set_time_limit(0);
$imgline="";
function preg_substr($start, $end, $str)
$temp = preg_split($start, $str);
$content = preg_split($end, $temp[1]);
return $content[0];
function str_substr($start, $end, $str)
$temp = explode($start, $str, 2);
$content = explode($end, $temp[1], 2);
return $content[0];
function microtime_float()
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
function getiurl($id)
global $imgline;
$str=$imgline[$id];
return $str;
$abcd=file_get_contents("http://www.chinanews.com/theory.shtml");
$hello = explode('
',str_substr('

', '
', $abcd));
$abcd2=file_get_contents("http://www.chinanews.com/jiankang.shtml");
$hello2 = explode('
',str_substr('

', '
', $abcd2));
$abcd3=file_get_contents("http://www.chinanews.com/scroll-news/news2.html");
$hello3 = explode('
',str_substr('

', '
', $abcd3));
$abcd4=file_get_contents("http://www.chinanews.com/society.shtml");
$hello4 = explode('
',str_substr('

', '
', $abcd4));
$abcd5=file_get_contents("http://www.chinanews.com/scroll-news/news2.html");
$hello5 = explode('
',str_substr('

', '
', $abc5));
$abcd6=file_get_contents("http://www.chinanews.com/jiankang.shtml");
$hello6 = explode('
',str_substr('

', '
', $abcd6));
$abcd7=file_get_contents("http://www.chinanews.com/theory.shtml");
$hello7 = explode('
',str_substr('

', '
', $abcd7));
$abcd8=file_get_contents("http://www.chinanews.com/society.shtml");
$hello8 = explode('
',str_substr('

', '
', $abcd8));
$abcd9=file_get_contents("http://www.chinanews.com/world.shtml");
$hello9 = explode('
',str_substr('

', '
', $abcd9));
$abcd10=file_get_contents("http://www.chinanews.com/scroll-news/news1.html");
$hello10 = explode('
',str_substr('

', '
', $abcd10));
$abcd11=file_get_contents("http://www.chinanews.com/scroll-news/news2.html");
$hello11 = explode('
',str_substr('

', '
', $abcd11));
$abcd12=file_get_contents("http://www.chinanews.com/scroll-news/news3.html");
$hello12 = explode('
',str_substr('

', '
', $abcd12));
$abcd13=file_get_contents("http://www.chinanews.com/scroll-news/news4.html");
$hello13 = explode('
',str_substr('

', '
', $abcd13));
$myfile = fopen($txtnames, "w") or die("错误博客 cuowu.com Unable to open file!");
for($index=0;$index

$hello[$index]=str_substr('shtml">', '', $hello[$index]);
echo $hello[$index]."
";
fwrite($myfile, $hello[$index]."
");
for($index=0;$index

$hello2[$index]=str_substr('shtml">', '', $hello2[$index]);
echo $hello2[$index]."
";
fwrite($myfile, $hello2[$index]."
");
for($index=0;$index

$hello3[$index]=str_substr('shtml">', '', $hello3[$index]);
echo $hello3[$index]."
";
fwrite($myfile, $hello3[$index]."
");
for($index=0;$index

$hello4[$index]=str_substr('shtml">', '', $hello4[$index]);
echo $hello4[$index]."
";
fwrite($myfile, $hello4[$index]."
");
for($index=0;$index

$hello5[$index]=str_substr('shtml">', '', $hello5[$index]);
echo $hello5[$index]."
";
fwrite($myfile, $hello5[$index]."
");
for($index=0;$index

$hello6[$index]=str_substr('shtml">', '', $hello6[$index]);
echo $hello6[$index]."
";
fwrite($myfile, $hello6[$index]."
");
for($index=0;$index

$hello7[$index]=str_substr('shtml">', '', $hello7[$index]);
echo $hello7[$index]."
";
fwrite($myfile, $hello7[$index]."
");
for($index=0;$index

$hello8[$index]=str_substr('shtml">', '', $hello8[$index]);
echo $hello8[$index]."
";
fwrite($myfile, $hello8[$index]."
");
for($index=0;$index

$hello9[$index]=str_substr('shtml">', '', $hello9[$index]);
echo $hello9[$index]."
";
fwrite($myfile, $hello9[$index]."
");
for($index=0;$index

$hello10[$index]=str_substr('shtml">', '', $hello10[$index]);
echo $hello10[$index]."
";
fwrite($myfile, $hello10[$index]."
");
for($index=0;$index

$hello11[$index]=str_substr('shtml">', '', $hello11[$index]);
echo $hello11[$index]."
";
fwrite($myfile, $hello11[$index]."
");
for($index=0;$index

$hello12[$index]=str_substr('shtml">', '', $hello12[$index]);
echo $hello12[$index]."
";
fwrite($myfile, $hello12[$index]."
");
for($index=0;$index

$hello13[$index]=str_substr('shtml">', '', $hello13[$index]);
echo $hello13[$index]."
";
fwrite($myfile, $hello13[$index]."
");
fclose($myfile);

cuowu_biaotiA.php


$txtnames ="cuowucom/biaoti/cuowucom-biaotiA.txt";
header("refresh:6;url=./cuowucom_biaotiB.php");
set_time_limit(0);
$imgline="";
function preg_substr($start, $end, $str)
$temp = preg_split($start, $str);
$content = preg_split($end, $temp[1]);
return $content[0];
function str_substr($start, $end, $str)
$temp = explode($start, $str, 2);
$content = explode($end, $temp[1], 2);
return $content[0];
function microtime_float()
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
function getiurl($id)
global $imgline;
$str=$imgline[$id];
return $str;
$abcd=file_get_contents("http://www.chinanews.com/society.shtml");
$hello = explode('
',str_substr('

', '
', $abcd));
$abcd2=file_get_contents("http://www.chinanews.com/scroll-news/news5.html");
$hello2 = explode('
',str_substr('

', '
', $abcd2));
$abcd3=file_get_contents("http://www.chinanews.com/scroll-news/news6.html");
$hello3 = explode('
',str_substr('

', '
', $abcd3));
$abcd4=file_get_contents("http://www.chinanews.com/scroll-news/news7.html");
$hello4 = explode('
',str_substr('

', '
', $abcd4));
$abcd5=file_get_contents("http://www.chinanews.com/scroll-news/news8.html");
$hello5 = explode('
',str_substr('

', '
', $abcd5));
$abcd6=file_get_contents("http://www.chinanews.com/mil/news.shtml");
$hello6 = explode('
',str_substr('

', '
', $abcd6));
$abcd7=file_get_contents("http://www.chinanews.com/scroll-news/news5.html");
$hello7 = explode('
',str_substr('

', '
', $abcd7));
$abcd8=file_get_contents("http://www.chinanews.com/scroll-news/news6.html");
$hello8 = explode('
',str_substr('

', '
', $abcd8));
$abcd9=file_get_contents("http://www.chinanews.com/scroll-news/news7.html");
$hello9 = explode('
',str_substr('

', '
', $abcd9));
$abcd10=file_get_contents("http://www.chinanews.com/scroll-news/news2.html");
$hello10 = explode('
',str_substr('

', '
', $abcd10));
$myfile = fopen($txtnames, "w") or die(" Unable to open file!");
for($index=0;$index

$hello[$index]=str_substr('shtml">', '', $hello[$index]);
echo $hello[$index]."
";
fwrite($myfile, $hello[$index]."
");
for($index=0;$index

$hello2[$index]=str_substr('shtml">', '', $hello2[$index]);
echo $hello2[$index]."
";
fwrite($myfile, $hello2[$index]."
");
for($index=0;$index

$hello3[$index]=str_substr('shtml">', '', $hello3[$index]);
echo $hello3[$index]."
";
fwrite($myfile, $hello3[$index]."
");
for($index=0;$index

$hello4[$index]=str_substr('shtml">', '', $hello4[$index]);
echo $hello4[$index]."
";
fwrite($myfile, $hello4[$index]."
");
for($index=0;$index

$hello5[$index]=str_substr('shtml">', '', $hello5[$index]);
echo $hello5[$index]."
";
fwrite($myfile, $hello5[$index]."
");
for($index=0;$index

$hello6[$index]=str_substr('shtml">', '', $hello6[$index]);
echo $hello6[$index]."
";
fwrite($myfile, $hello6[$index]."
");
for($index=0;$index

$hello7[$index]=str_substr('shtml">', '', $hello7[$index]);
echo $hello7[$index]."
";
fwrite($myfile, $hello7[$index]."
");
for($index=0;$index

$hello8[$index]=str_substr('shtml">', '', $hello8[$index]);
echo $hello8[$index]."
";
fwrite($myfile, $hello8[$index]."
");
for($index=0;$index

$hello9[$index]=str_substr('shtml">', '', $hello9[$index]);
echo $hello9[$index]."
";
fwrite($myfile, $hello9[$index]."
");
for($index=0;$index

$hello10[$index]=str_substr('shtml">', '', $hello10[$index]);
echo $hello10[$index]."
";
fwrite($myfile, $hello10[$index]."
");
fclose($myfile);

cuowu_biaotiB.php


$txtnames ="cuowucom/biaoti/cuowucom-biaotiB.txt";
header("refresh:26;url=./cuowucom_biaoti.php");
set_time_limit(0);
$imgline="";
function preg_substr($start, $end, $str)
$temp = preg_split($start, $str);
$content = preg_split($end, $temp[1]);
return $content[0];
function str_substr($start, $end, $str)
$temp = explode($start, $str, 2);
$content = explode($end, $temp[1], 2);
return $content[0];
function microtime_float()
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
function getiurl($id)
global $imgline;
$str=$imgline[$id];
return $str;
$abcd=file_get_contents("http://www.chinanews.com/compatriot.shtml");
$hello = explode('
',str_substr('

', '
', $abcd));
$abcd2=file_get_contents("http://www.chinanews.com/business/gd.shtml");
$hello2 = explode('
',str_substr('

', '
', $abcd2));
$abcd3=file_get_contents("http://www.chinanews.com/taiwan.shtml");
$hello3 = explode('
',str_substr('

', '
', $abcd3));
$abcd4=file_get_contents("http://www.chinanews.com/scroll-news/news1.html");
$hello4 = explode('
',str_substr('

', '
', $abcd4));
$abcd5=file_get_contents("http://www.chinanews.com/scroll-news/news2.html");
$hello5 = explode('
',str_substr('

', '
', $abcd5));
$abcd6=file_get_contents("http://www.chinanews.com/entertainment.shtml");
$hello6 = explode('
',str_substr('

', '
', $abcd6));
$abcd7=file_get_contents("http://www.chinanews.com/ty/gun-news.html");
$hello7 = explode('
',str_substr('

', '
', $abcd7));
$abcd8=file_get_contents("http://www.chinanews.com/wenhua.shtml");
$hello8 = explode('
',str_substr('

', '
', $abcd8));
$abcd9=file_get_contents("http://www.chinanews.com/scroll-news/news1.html");
$hello9 = explode('
',str_substr('

', '
', $abcd9));
$abcd10=file_get_contents("http://www.chinanews.com/scroll-news/news2.html");
$hello10 = explode('
',str_substr('

', '
', $abcd10));
$myfile = fopen($txtnames, "w") or die("错误博客Unable to open file!");
for($index=0;$index

$hello[$index]=str_substr('shtml">', '', $hello[$index]);
echo $hello[$index]."
";
fwrite($myfile, $hello[$index]."
");
for($index=0;$index

$hello2[$index]=str_substr('shtml">', '', $hello2[$index]);
echo $hello2[$index]."
";
fwrite($myfile, $hello2[$index]."
");
for($index=0;$index

$hello3[$index]=str_substr('shtml">', '', $hello3[$index]);
echo $hello3[$index]."
";
fwrite($myfile, $hello3[$index]."
");
for($index=0;$index

$hello4[$index]=str_substr('shtml">', '', $hello4[$index]);
echo $hello4[$index]."
";
fwrite($myfile, $hello4[$index]."
");
for($index=0;$index

$hello5[$index]=str_substr('shtml">', '', $hello5[$index]);
echo $hello5[$index]."
";
fwrite($myfile, $hello5[$index]."
");
for($index=0;$index

$hello6[$index]=str_substr('shtml">', '', $hello6[$index]);
echo $hello6[$index]."
";
fwrite($myfile, $hello6[$index]."
");
for($index=0;$index

$hello7[$index]=str_substr('shtml">', '', $hello7[$index]);
echo $hello7[$index]."
";
fwrite($myfile, $hello7[$index]."
");
for($index=0;$index

$hello8[$index]=str_substr('shtml">', '', $hello8[$index]);
echo $hello8[$index]."
";
fwrite($myfile, $hello8[$index]."
");
for($index=0;$index

$hello9[$index]=str_substr('shtml">', '', $hello9[$index]);
echo $hello9[$index]."
";
fwrite($myfile, $hello9[$index]."
");
for($index=0;$index

$hello10[$index]=str_substr('shtml">', '', $hello10[$index]);
echo $hello10[$index]."
";
fwrite($myfile, $hello10[$index]."
");
fclose($myfile);

以上就是错误博客(cuowu.com)分享的内容为《PHP24小时自动更新采集标题》。感谢您的阅读。更多原创文章搜索“错误博客”。

特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。

Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.

相关推荐
热点推荐
克罗地亚点球为何不重罚?规则明文指出攻方提前进线情况

克罗地亚点球为何不重罚?规则明文指出攻方提前进线情况

懂球帝
2024-06-16 01:59:08
普京表示:不攻击北约、不使用核武并愿意谈判!难道要服软了?

普京表示:不攻击北约、不使用核武并愿意谈判!难道要服软了?

翻开历史和现实
2024-06-13 22:56:43
欧洲杯B组积分榜:西班牙领跑死亡之组,意大利第二克罗地亚垫底

欧洲杯B组积分榜:西班牙领跑死亡之组,意大利第二克罗地亚垫底

直播吧
2024-06-16 05:09:10
放贷者报案,广东云浮实业家被抓

放贷者报案,广东云浮实业家被抓

刘虎和朋友们
2024-06-15 21:10:08
神奇换人!两小将临危受命直取关键两分,主导者不是蔡斌,而是她

神奇换人!两小将临危受命直取关键两分,主导者不是蔡斌,而是她

理工男评篮球
2024-06-16 00:29:00
杰伦-格林与大17岁的女友逛街还推着刚满月的小女儿

杰伦-格林与大17岁的女友逛街还推着刚满月的小女儿

直播吧
2024-06-16 10:08:23
洗米嫂不再炫富只愿平安!和22岁大女儿外出骑行,母女同框似姐妹

洗米嫂不再炫富只愿平安!和22岁大女儿外出骑行,母女同框似姐妹

娱小小新
2024-06-15 15:06:46
吴谨言横店剧组被偶遇,又瘦又矮法令纹明显,脸巴掌大还有点垮

吴谨言横店剧组被偶遇,又瘦又矮法令纹明显,脸巴掌大还有点垮

鑫鑫说说
2024-06-15 16:24:04
脑子进多少水才会买这么贵又这么丑的衣服

脑子进多少水才会买这么贵又这么丑的衣服

白宸侃片
2024-06-16 00:39:51
福建多地持续暴雨已达7天 多条江河超警戒水位

福建多地持续暴雨已达7天 多条江河超警戒水位

北青网-北京青年报
2024-06-16 12:01:03
官宣!河南队又迎来新金主出手相助,刚亮相就带来一条国脚大鱼

官宣!河南队又迎来新金主出手相助,刚亮相就带来一条国脚大鱼

罗掌柜体育
2024-06-15 12:06:06
以色列三大港口都遭到火力封锁,相当于已经被按住命脉!

以色列三大港口都遭到火力封锁,相当于已经被按住命脉!

笔墨V
2024-06-16 03:31:34
1968年,张大千的四姨太徐雯波,正恭敬地跪在地上拜师

1968年,张大千的四姨太徐雯波,正恭敬地跪在地上拜师

视点历史
2024-06-15 17:59:58
养老金上调基本正式确定,1950和1960出生的人,上调会有差异吗?

养老金上调基本正式确定,1950和1960出生的人,上调会有差异吗?

奇名呀
2024-06-11 09:02:33
江苏海安发现罕见的三角桥,三个桥面却没有桥墩,如今成了危桥

江苏海安发现罕见的三角桥,三个桥面却没有桥墩,如今成了危桥

大宗看萌宠
2024-06-16 07:05:18
世联赛最新排名出炉,中国女排第六,三球队争最后一个总决赛席位

世联赛最新排名出炉,中国女排第六,三球队争最后一个总决赛席位

湘楚风云
2024-06-16 02:19:01
39.7℃,差点截肢!医生: "致死率很高"...

39.7℃,差点截肢!医生: "致死率很高"...

鲁中晨报
2024-06-16 09:35:17
官方回应:他俩均已离婚!

官方回应:他俩均已离婚!

沈阳地铁第一时间
2024-06-15 13:16:10
揭秘阿里巴巴全球数学竞赛:奖金400万元,“北大韦神”曾获金奖

揭秘阿里巴巴全球数学竞赛:奖金400万元,“北大韦神”曾获金奖

上游新闻
2024-06-15 15:28:36
过“紧日子”的地方政府,已经把手伸进老百姓的口袋里去了

过“紧日子”的地方政府,已经把手伸进老百姓的口袋里去了

浮事记
2024-06-03 11:48:21
2024-06-16 15:06:44
创作者_89QN
创作者_89QN
斜杠青年分享网络推广知识。
445文章数 371关注度
往期回顾 全部

科技要闻

iPhone 16会杀死大模型APP吗?

头条要闻

牛弹琴:梅洛尼和马克龙吵了一架 晚宴上眼神可"杀人"

头条要闻

牛弹琴:梅洛尼和马克龙吵了一架 晚宴上眼神可"杀人"

体育要闻

没人永远年轻 但青春如此无敌还是离谱了些

娱乐要闻

上影节红毯:倪妮好松弛,娜扎吸睛

财经要闻

打断妻子多根肋骨 上市公司创始人被公诉

汽车要闻

售17.68万-21.68万元 极狐阿尔法S5正式上市

态度原创

数码
本地
时尚
艺术
公开课

数码要闻

优派 XG323-4K-OLED-2 显示器预告:原生 10bit、全功能 Type-C

本地新闻

粽情一夏|海河龙舟赛,竟然成了外国人的大party!

女人年过40岁,会不会打扮差异太大了,穿对显年轻、穿错显老

艺术要闻

穿越时空的艺术:《马可·波罗》AI沉浸影片探索人类文明

公开课

近视只是视力差?小心并发症

无障碍浏览 进入关怀版