新浪新聞小偷1.

<html>
<head>
<meta http-equiv="Refresh" content="60">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type&quo " /> 国内精品国产成人国产三级粉色,97精品伊人久久久大香线蕉,亚洲精品欧洲精品

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

新浪新聞小偷


新浪新聞小偷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 主機名
$namesql="????"; // MYSQL 用戶名
$passsql="????"; // MYSQL 密碼
$lib="news"; // 數據庫名
$table="news"; // 數據庫表名
$filename="http://news.sina.com.cn/news1000/index.shtml"; // 抓取的新聞頁
$keytop="新聞開始"; // 新聞開始關鍵詞
$keybottom="新聞結束"; // 新聞結束關鍵詞

$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("新聞結束",$message,$result))
{
$sign = 0;
}
}
fclose($handle);
?>

php技術新浪新聞小偷,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 札达县| 九龙县| 巫山县| 陇南市| 城市| 横峰县| 巴林右旗| 郸城县| 隆德县| 仁布县| 冕宁县| 湖州市| 长白| 龙南县| 历史| 偏关县| 正阳县| 鹤壁市| 武威市| 英超| 井冈山市| 桂阳县| 葵青区| 哈密市| 天水市| 阜南县| 五寨县| 公主岭市| 星子县| 永泰县| 福贡县| 邛崃市| 英德市| 静宁县| 宜丰县| 延津县| 聂拉木县| 襄汾县| 调兵山市| 河西区| 浙江省|