最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

新浪新聞小偷

 更新時(shí)間:2006年10月09日 00:00:00   作者:  

新浪新聞小偷 1.

<html>
<head>
<meta http-equiv="Refresh" content="60">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html"; charset="??????">
<title>新浪_新聞抓取程序</title>
</head>
<body>

<center><img src="pic.gif"></center>
<?
$host="127.0.0.1"; // MYSQL 主機(jī)名
$namesql="????"; // MYSQL 用戶名
$passsql="????"; // MYSQL 密碼
$lib="news"; // 數(shù)據(jù)庫名
$table="news"; // 數(shù)據(jù)庫表名
$filename="http://news.sina.com.cn/news1000/index.shtml"; // 抓取的新聞頁
$keytop="新聞開始"; // 新聞開始關(guān)鍵詞
$keybottom="新聞結(jié)束"; // 新聞結(jié)束關(guān)鍵詞

$conn=mysql_connect($host,$namesql,$passsql);
mysql_select_db($lib,$conn);

$fp=fopen($filename,"r",1);
$flag=0; $add=""; $found=0; $end=0; $i=0; $temp[4]="";
while(!$end==1){
while(!$flag==1){
$word=fgetc($fp);
$add=$add.$word;
if($word=='<' and strlen($add)==1){ $flag=0; }
if($word=='<' and strlen($add)!=1){ $flag=1; $add=substr($add,0,strlen($add)-1); }
if($word=='>'){ $flag=1; } }

if(strchr($add,$keytop)){ $found=1; }
if(strchr($add,$keybottom)){ $found=0; $end=1; }
if(((strchr($add,'<')==True and strchr($add,'href')==True) or strchr($add,'<')==False) and $found==1){ $text[$i]=$add; $i++; }
if($word=='<' and $flag==1){ $add=$word; $flag=0; } else { $add=""; $flag=0; } }
fclose($fp);

for($i=1;$i<sizeof($text)-1;$i+=5){
$temp[1]=$text[$i+1]; $temp[2]=$text[$i+2]; $temp[3]=$text[$i+3]; $temp[4]=$text[$i+4];
$ins="select * from $table where TITLE='$temp[3]'";
$list=mysql_query($ins,$conn);
@$count=mysql_num_rows($list);
if($count==0){
$ins="insert into $table(TYPE,URL,TITLE,DATE) values ('$temp[1]','$temp[2]','$temp[3]','$temp[4]')";
$list=mysql_query($ins,$conn); } }
mysql_close($conn);
?>

</body>
</html>



2.<?
$handle = fopen("http://news.sina.com.cn/news1000/","r");
$sign = 0;
while(!feof($handle))
{
$message = fgets($handle,512);
if($sign == 1)
{
print("$message");
}
if(ereg("新聞開始",$message,$result))
{
$sign = 1;
}
else if(ereg("新聞結(jié)束",$message,$result))
{
$sign = 0;
}
}
fclose($handle);
?>

相關(guān)文章

最新評論

玉山县| 香格里拉县| 海口市| 松江区| 中西区| 通化市| 高尔夫| 平潭县| 通城县| 古丈县| 万宁市| 偃师市| 万安县| 尉氏县| 武邑县| 新昌县| 绥中县| 平度市| 大田县| 察雅县| 咸宁市| 厦门市| 津市市| 驻马店市| 武邑县| 安仁县| 乌兰浩特市| 金门县| 红原县| 金湖县| 望江县| 友谊县| 临海市| 尉氏县| 盐池县| 清徐县| 乌兰察布市| 会理县| 清水河县| 新疆| 安平县|