您的位置 首页 php

PHP24小时自动更新采集标题

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

一、自动采集原理

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

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

二、PHP采集标题到txt

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

cuowu_biaoti.php

<?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(“#34;);
$hello = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd));

$abcd2=file_get_contents(“#34;);
$hello2 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd2));

$abcd3=file_get_contents(“#34;);
$hello3 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd3));

$abcd4=file_get_contents(“#34;);
$hello4 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd4));

$abcd5=file_get_contents(“#34;);
$hello5 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abc5));

$abcd6=file_get_contents(“#34;);
$hello6 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd6));

$abcd7=file_get_contents(“#34;);
$hello7 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd7));

$abcd8=file_get_contents(“#34;);
$hello8 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd8));

$abcd9=file_get_contents(“#34;);
$hello9 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd9));

$abcd10=file_get_contents(“#34;);
$hello10 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd10));

$abcd11=file_get_contents(“#34;);
$hello11 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd11));

$abcd12=file_get_contents(“#34;);
$hello12 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd12));
$abcd13=file_get_contents(“#34;);
$hello13 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd13));

$myfile = fopen($txtnames, “w”) or die(“错误博客 cuowu.com Unable to open file!”);

for($index=0;$index<count($hello)-1;$index++)
{
$hello[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello[$index]);
echo $hello[$index].”</br>”;
fwrite($myfile, $hello[$index].”
“);
}

for($index=0;$index<count($hello2)-1;$index++)
{
$hello2[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello2[$index]);
echo $hello2[$index].”</br>”;
fwrite($myfile, $hello2[$index].”
“);
}

for($index=0;$index<count($hello3)-1;$index++)
{
$hello3[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello3[$index]);
echo $hello3[$index].”</br>”;
fwrite($myfile, $hello3[$index].”
“);
}

for($index=0;$index<count($hello4)-1;$index++)
{
$hello4[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello4[$index]);
echo $hello4[$index].”</br>”;
fwrite($myfile, $hello4[$index].”
“);
}

for($index=0;$index<count($hello5)-1;$index++)
{
$hello5[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello5[$index]);
echo $hello5[$index].”</br>”;
fwrite($myfile, $hello5[$index].”
“);
}

for($index=0;$index<count($hello6)-1;$index++)
{
$hello6[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello6[$index]);
echo $hello6[$index].”</br>”;
fwrite($myfile, $hello6[$index].”
“);
}

for($index=0;$index<count($hello7)-1;$index++)
{
$hello7[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello7[$index]);
echo $hello7[$index].”</br>”;
fwrite($myfile, $hello7[$index].”
“);
}

for($index=0;$index<count($hello8)-1;$index++)
{
$hello8[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello8[$index]);
echo $hello8[$index].”</br>”;
fwrite($myfile, $hello8[$index].”
“);
}
for($index=0;$index<count($hello9)-1;$index++)
{
$hello9[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello9[$index]);
echo $hello9[$index].”</br>”;
fwrite($myfile, $hello9[$index].”
“);
}

for($index=0;$index<count($hello10)-1;$index++)
{
$hello10[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello10[$index]);
echo $hello10[$index].”</br>”;
fwrite($myfile, $hello10[$index].”
“);
}

for($index=0;$index<count($hello11)-1;$index++)
{
$hello11[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello11[$index]);
echo $hello11[$index].”</br>”;
fwrite($myfile, $hello11[$index].”
“);
}

for($index=0;$index<count($hello12)-1;$index++)
{
$hello12[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello12[$index]);
echo $hello12[$index].”</br>”;
fwrite($myfile, $hello12[$index].”
“);
}

for($index=0;$index<count($hello13)-1;$index++)
{
$hello13[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello13[$index]);
echo $hello13[$index].”</br>”;
fwrite($myfile, $hello13[$index].”
“);
}

fclose($myfile);

cuowu_biaotiA.php

<?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(“#34;);
$hello = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd));

$abcd2=file_get_contents(“#34;);
$hello2 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd2));

$abcd3=file_get_contents(“#34;);
$hello3 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd3));

$abcd4=file_get_contents(“#34;);
$hello4 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd4));
$abcd5=file_get_contents(“#34;);
$hello5 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd5));

$abcd6=file_get_contents(“#34;);
$hello6 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd6));

$abcd7=file_get_contents(“#34;);
$hello7 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd7));

$abcd8=file_get_contents(“#34;);
$hello8 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd8));

$abcd9=file_get_contents(“#34;);
$hello9 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd9));
$abcd10=file_get_contents(“#34;);
$hello10 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd10));

$myfile = fopen($txtnames, “w”) or die(” Unable to open file!”);

for($index=0;$index<count($hello)-1;$index++)
{
$hello[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello[$index]);
echo $hello[$index].”</br>”;
fwrite($myfile, $hello[$index].”
“);
}

for($index=0;$index<count($hello2)-1;$index++)
{
$hello2[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello2[$index]);
echo $hello2[$index].”</br>”;
fwrite($myfile, $hello2[$index].”
“);
}

for($index=0;$index<count($hello3)-1;$index++)
{
$hello3[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello3[$index]);
echo $hello3[$index].”</br>”;
fwrite($myfile, $hello3[$index].”
“);
}

for($index=0;$index<count($hello4)-1;$index++)
{
$hello4[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello4[$index]);
echo $hello4[$index].”</br>”;
fwrite($myfile, $hello4[$index].”
“);
}

for($index=0;$index<count($hello5)-1;$index++)
{
$hello5[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello5[$index]);
echo $hello5[$index].”</br>”;
fwrite($myfile, $hello5[$index].”
“);
}

for($index=0;$index<count($hello6)-1;$index++)
{
$hello6[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello6[$index]);
echo $hello6[$index].”</br>”;
fwrite($myfile, $hello6[$index].”
“);
}

for($index=0;$index<count($hello7)-1;$index++)
{
$hello7[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello7[$index]);
echo $hello7[$index].”</br>”;
fwrite($myfile, $hello7[$index].”
“);
}

for($index=0;$index<count($hello8)-1;$index++)
{
$hello8[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello8[$index]);
echo $hello8[$index].”</br>”;
fwrite($myfile, $hello8[$index].”
“);
}
for($index=0;$index<count($hello9)-1;$index++)
{
$hello9[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello9[$index]);
echo $hello9[$index].”</br>”;
fwrite($myfile, $hello9[$index].”
“);
}

for($index=0;$index<count($hello10)-1;$index++)
{
$hello10[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello10[$index]);
echo $hello10[$index].”</br>”;
fwrite($myfile, $hello10[$index].”
“);
}

fclose($myfile);

cuowu_biaotiB.php

<?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(“#34;);
$hello = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd));

$abcd2=file_get_contents(“#34;);
$hello2 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd2));

$abcd3=file_get_contents(“#34;);
$hello3 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd3));

$abcd4=file_get_contents(“#34;);
$hello4 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd4));
$abcd5=file_get_contents(“#34;);
$hello5 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd5));

$abcd6=file_get_contents(“#34;);
$hello6 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd6));

$abcd7=file_get_contents(“#34;);
$hello7 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd7));

$abcd8=file_get_contents(“#34;);
$hello8 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd8));

$abcd9=file_get_contents(“#34;);
$hello9 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd9));

$abcd10=file_get_contents(“#34;);
$hello10 = explode(‘<div class=”dd_time”>’,str_substr(‘<div class=”content_list”>
‘, ‘<div id=”footerAd”>’, $abcd10));

$myfile = fopen($txtnames, “w”) or die(“错误博客Unable to open file!”);

for($index=0;$index<count($hello)-1;$index++)
{
$hello[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello[$index]);
echo $hello[$index].”</br>”;
fwrite($myfile, $hello[$index].”
“);
}

for($index=0;$index<count($hello2)-1;$index++)
{
$hello2[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello2[$index]);
echo $hello2[$index].”</br>”;
fwrite($myfile, $hello2[$index].”
“);
}

for($index=0;$index<count($hello3)-1;$index++)
{
$hello3[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello3[$index]);
echo $hello3[$index].”</br>”;
fwrite($myfile, $hello3[$index].”
“);
}

for($index=0;$index<count($hello4)-1;$index++)
{
$hello4[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello4[$index]);
echo $hello4[$index].”</br>”;
fwrite($myfile, $hello4[$index].”
“);
}

for($index=0;$index<count($hello5)-1;$index++)
{
$hello5[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello5[$index]);
echo $hello5[$index].”</br>”;
fwrite($myfile, $hello5[$index].”
“);
}

for($index=0;$index<count($hello6)-1;$index++)
{
$hello6[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello6[$index]);
echo $hello6[$index].”</br>”;
fwrite($myfile, $hello6[$index].”
“);
}

for($index=0;$index<count($hello7)-1;$index++)
{
$hello7[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello7[$index]);
echo $hello7[$index].”</br>”;
fwrite($myfile, $hello7[$index].”
“);
}

for($index=0;$index<count($hello8)-1;$index++)
{
$hello8[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello8[$index]);
echo $hello8[$index].”</br>”;
fwrite($myfile, $hello8[$index].”
“);
}
for($index=0;$index<count($hello9)-1;$index++)
{
$hello9[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello9[$index]);
echo $hello9[$index].”</br>”;
fwrite($myfile, $hello9[$index].”
“);
}

for($index=0;$index<count($hello10)-1;$index++)
{
$hello10[$index]=str_substr(‘shtml”>’, ‘</a>’, $hello10[$index]);
echo $hello10[$index].”</br>”;
fwrite($myfile, $hello10[$index].”
“);
}

fclose($myfile);

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

文章来源:智云一二三科技

文章标题:PHP24小时自动更新采集标题

文章地址:https://www.zhihuclub.com/77730.shtml

关于作者: 智云科技

热门文章

网站地图