data/attachment/common/编程

编程

    今日:0| 主题:21
收藏本版
发表新帖

[php语言] 程序人生 新浪新闻小偷

[复制链接] [提交至百度]
夜风 发表于 2019-11-21 03:33:03
971 0

马上注册,下载资源,享用更多功能,让你轻松玩转网站

您需要 登录 才可以下载或查看,没有帐号?立即注册

x



新浪新闻小偷 1
  1. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"><html></span>
  2. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"><head></span>
  3. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"><meta http-equiv="Refresh" content="60"></span>
  4. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"><META HTTP-EQUIV="Pragma" CONTENT="no-cache"></span>
  5. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"><meta http-equiv="Content-Type" content="text/html"; charset="??????"></span>
  6. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"><title>新浪_新闻抓取程序</title></span>
  7. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"></head></span>
  8. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"><body></span>

  9. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"><center><img src="pic.gif"></center></span>
  10. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"><?</span>
  11. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$host="127.0.0.1"; // MYSQL 主机名</span>
  12. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$namesql="????"; // MYSQL 用户名</span>
  13. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$passsql="????"; // MYSQL 密码</span>
  14. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$lib="news"; // 数据库名</span>
  15. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$table="news"; // 数据库表名</span>
  16. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$filename="http://news.sina.com.cn/news1000/index.shtml"; // 抓取的新闻页</span>
  17. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$keytop="新闻开始"; // 新闻开始关键词</span>
  18. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$keybottom="新闻结束"; // 新闻结束关键词</span>

  19. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$conn=mysql_connect($host,$namesql,$passsql);</span>
  20. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">mysql_select_db($lib,$conn);</span>

  21. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$fp=fopen($filename,"r",1);</span>
  22. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$flag=0; $add=""; $found=0; $end=0; $i=0; $temp[4]="";</span>
  23. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">while(!$end==1){</span>
  24. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">while(!$flag==1){</span>
  25. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$word=fgetc($fp);</span>
  26. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$add=$add.$word;</span>
  27. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">if($word=='<' and strlen($add)==1){ $flag=0; }</span>
  28. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">if($word=='<' and strlen($add)!=1){ $flag=1; $add=substr($add,0,strlen($add)-1); }</span>
  29. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">if($word=='>'){ $flag=1; } }</span>

  30. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">if(strchr($add,$keytop)){ $found=1; }</span>
  31. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">if(strchr($add,$keybottom)){ $found=0; $end=1; }</span>
  32. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">if(((strchr($add,'<')==True and strchr($add,'href')==True) or strchr($add,'<')==False) and $found==1){ $text[$i]=$add; $i++; } </span>
  33. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">if($word=='<' and $flag==1){ $add=$word; $flag=0; } else { $add=""; $flag=0; } }</span>
  34. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">fclose($fp);</span>

  35. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">for($i=1;$i<sizeof($text)-1;$i+=5){ </span>
  36. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$temp[1]=$text[$i+1]; $temp[2]=$text[$i+2]; $temp[3]=$text[$i+3]; $temp[4]=$text[$i+4];</span>
  37. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$ins="select * from $table where TITLE='$temp[3]'";</span>
  38. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$list=mysql_query($ins,$conn); </span>
  39. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">@$count=mysql_num_rows($list);</span>
  40. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">if($count==0){</span>
  41. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$ins="insert into $table(TYPE,URL,TITLE,DATE) values ('$temp[1]','$temp[2]','$temp[3]','$temp[4]')";</span>
  42. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">$list=mysql_query($ins,$conn); } }</span>
  43. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">mysql_close($conn);</span>
  44. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);">?></span>

  45. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"></body></span>
  46. <span style="font-family: &quot;Microsoft Yahei&quot;, Tahoma, Simsun; background-color: rgb(255, 255, 255);"></html></span>
复制代码
2.
  1. <?
  2. $handle = fopen("http://news.sina.com.cn/news1000/","r");
  3. $sign = 0;
  4. while(!feof($handle))
  5. {
  6. $message = fgets($handle,512);
  7. if($sign == 1)
  8. {
  9. print("$message");
  10. }
  11. if(ereg("新闻开始",$message,$result))
  12. {
  13. $sign = 1;
  14. }
  15. else if(ereg("新闻结束",$message,$result))
  16. {
  17. $sign = 0;
  18. }
  19. }
  20. fclose($handle);
  21. ?>
复制代码


 新浪新闻小偷  编程 033303pzfswhsuhmfzfcfi
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

推荐阅读

平台简介

六六下载网(666现在.cn),中国最大的电商设计师交流平台。最活跃的电商设计师学习交流分享社区。集原创作品+灵感图库+经验教程+设计专访+设计培训+社群活动为一体,全方位服务电商设计师。成立3年来,聚集20万电商设计师,定期线下设计沙龙,覆盖北京、上海、广州、杭州等城市计

QQ|Archiver|手机版|小黑屋|666下载网 ( 粤ICP备16097146号-5 )|网站地图  

Powered by 金易德.cn! X3.4  © 2014-2018 深圳市龙岗区金易徳贸易商行   增值电信业务经营许可证:粤B2-20140196

返回顶部 返回列表