<?
//作者:shuteer (有问题请来bbs.phpabc.com)
//网站:http://www.phpabc.com
//已经取得入库数据演示地址:http://www.phpabc.com/class.php?pg=1&sid=21&cid=48
//任何人可以修改,复制发布此小程序,但请保留这些注释,唯一的要求。
//所采集的页面:http://ent.tom.com/movie/deve/index.html (电影动态,仅此一页)
//由于总共就只有70条数据,所以没有日志记录功能.
//通用的程序演示,你只能修改下面INSERT INTO 成自己的数据库语句。
session_start();
$pre="http://ent.tom.com";
$url="http://ent.tom.com/movie/deve/index.html";
$html=".html";
if(!isset($_GET['id']))
{
$str=file_get_contents($url);
preg_match_all("/<a href=(.+?).html target=\"_blank\" class=indexlist>(.+?)<\/a>/",$str,$lines);
for($i=0;$i < count($lines[1]);$i++)
{
$article[$i]['url']=$pre.trim($lines[1][$i]).$html;
$article[$i]['title']=addslashes(trim($lines[2][$i]));
}
$_SESSION['s']=serialize($article);
echo "<script>window.location.href='".$_SERVER['PHP_SELF']."?id=0';</script>";
}else
{
$get_article=unserialize($_SESSION['s']);
$m=intval($_GET['id']);
if($m >= count($get_article))
{
echo $get_sql;
exit("已经抓取完成");
}else
{
$get_title=addslashes(trim($get_article[$m]['title']));
$p=file_get_contents($get_article[$m]['url']);
$content=explode('<!---content--->',$p);
$get_content=addslashes(filter($content[1]));
$time=time();
$get_sql="INSERT INTO sdf_article VALUES ('','21','48','$get_title','shuteer','tom','$time','0','$get_content','1','电影,影视,明星,新片','0');\r\n";
$fp=fopen("move.sql",'a');
fwrite($fp,$get_sql);
fclose($fp);
$m++;
echo $get_title."已经抓取";
echo "<script>window.location.href='".$_SERVER['PHP_SELF']."?id=$m';</script>";
}
}
function filter($str)
{
$str=preg_replace("/<script(.*)<\/script>/i",'',$str);
$str=str_replace("/script/showpic.php?picfile=",'http://img.ent.tom.com'.$img,$str);
return $str;
}
?>
//作者:shuteer (有问题请来bbs.phpabc.com)
//网站:http://www.phpabc.com
//已经取得入库数据演示地址:http://www.phpabc.com/class.php?pg=1&sid=21&cid=48
//任何人可以修改,复制发布此小程序,但请保留这些注释,唯一的要求。
//所采集的页面:http://ent.tom.com/movie/deve/index.html (电影动态,仅此一页)
//由于总共就只有70条数据,所以没有日志记录功能.
//通用的程序演示,你只能修改下面INSERT INTO 成自己的数据库语句。
session_start();
$pre="http://ent.tom.com";
$url="http://ent.tom.com/movie/deve/index.html";
$html=".html";
if(!isset($_GET['id']))
{
$str=file_get_contents($url);
preg_match_all("/<a href=(.+?).html target=\"_blank\" class=indexlist>(.+?)<\/a>/",$str,$lines);
for($i=0;$i < count($lines[1]);$i++)
{
$article[$i]['url']=$pre.trim($lines[1][$i]).$html;
$article[$i]['title']=addslashes(trim($lines[2][$i]));
}
$_SESSION['s']=serialize($article);
echo "<script>window.location.href='".$_SERVER['PHP_SELF']."?id=0';</script>";
}else
{
$get_article=unserialize($_SESSION['s']);
$m=intval($_GET['id']);
if($m >= count($get_article))
{
echo $get_sql;
exit("已经抓取完成");
}else
{
$get_title=addslashes(trim($get_article[$m]['title']));
$p=file_get_contents($get_article[$m]['url']);
$content=explode('<!---content--->',$p);
$get_content=addslashes(filter($content[1]));
$time=time();
$get_sql="INSERT INTO sdf_article VALUES ('','21','48','$get_title','shuteer','tom','$time','0','$get_content','1','电影,影视,明星,新片','0');\r\n";
$fp=fopen("move.sql",'a');
fwrite($fp,$get_sql);
fclose($fp);
$m++;
echo $get_title."已经抓取";
echo "<script>window.location.href='".$_SERVER['PHP_SELF']."?id=$m';</script>";
}
}
function filter($str)
{
$str=preg_replace("/<script(.*)<\/script>/i",'',$str);
$str=str_replace("/script/showpic.php?picfile=",'http://img.ent.tom.com'.$img,$str);
return $str;
}
?>
评论Feed: http://www.85815.com/feed.asp?q=comment&id=180
引用链接: http://www.85815.com/trackback.asp?id=180&key=
这篇日志没有评论.