新浪新聞小偷1.

<html>
<head>
<meta http-equiv="Refresh" content="60">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type&quo " /> 亚洲欧美网站,日本不卡一二三区,国产一区二区三区四区五区入口

色尼玛亚洲综合影院,亚洲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 主機(jī)名
$namesql="????"; // MYSQL 用戶名
$passsql="????"; // MYSQL 密碼
$lib="news"; // 數(shù)據(jù)庫(kù)名
$table="news"; // 數(shù)據(jù)庫(kù)表名
$filename="http://news.sina.com.cn/news1000/index.shtml"; // 抓取的新聞頁(yè)
$keytop="新聞開(kāi)始"; // 新聞開(kāi)始關(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("新聞開(kāi)始",$message,$result))
{
$sign = 1;
}
else if(ereg("新聞結(jié)束",$message,$result))
{
$sign = 0;
}
}
fclose($handle);
?>

php技術(shù)新浪新聞小偷,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 平昌县| 二手房| 汝阳县| 涞水县| 汝州市| 苍梧县| 阿合奇县| 克东县| 如东县| 彭阳县| 宣武区| 遂宁市| 嘉荫县| 洪江市| 台安县| 温泉县| 北票市| 丹巴县| 凤城市| 页游| 天长市| 永定县| 宾川县| 和硕县| 六枝特区| 沙雅县| 林芝县| 潜江市| 通许县| 杭锦后旗| 金山区| 磐石市| 怀化市| 丹寨县| 宝丰县| 池州市| 茌平县| 定南县| 鹤壁市| 兰考县| 辽源市|