分享一个自动采集获取新闻实时热点的php脚本

今天就来分享一个自动采集获取搜狗,百度新闻实时热点的php脚本。获取后自动保存为txt文本,方便调用和查看~

  1. // www.Testyuming.cn  Test玩站网  
  2. // 搜狗百度热点采集生成:  
  3. $strchulis="";  
  4. $sgresult="";  
  5. $baidustr1 = file_get_contents("http://top.baidu.com/buzz/top10.html");    
  6. $baidustr2 = file_get_contents("http://top.baidu.com/buzz?b=11&c=513&fr=topcategory_c513");    
  7. $baidustr3 = file_get_contents("http://top.baidu.com/buzz?b=344&c=513&fr=topcategory_c513");    
  8. for ($x=1; $x<=3; $x++) {  
  9.     $sgstr1 = file_get_contents("http://top.sogou.com/hot/sevendsnews_".$x.".html");    
  10.     $sgstr2 = file_get_contents("http://top.sogou.com/hot/shishi_".$x.".html");    
  11.     $sgstr3 = file_get_contents("http://top.sogou.com/movie/all_".$x.".html");    
  12.     $sgstr4 = file_get_contents("http://top.sogou.com/tvplay/all_".$x.".html");    
  13.     $sgstr5 = file_get_contents("http://top.sogou.com/tvshow/all_".$x.".html");    
  14.     $sgstr6 = file_get_contents("http://top.sogou.com/animation/all_".$x.".html");    
  15.     $sgstr7 = file_get_contents("http://top.sogou.com/book/all_".$x.".html");    
  16.     $sgstr8 = file_get_contents("http://top.sogou.com/song/newsong_".$x.".html");    
  17.     $sgstr9 = file_get_contents("http://top.sogou.com/game/all_".$x.".html");    
  18.     $sgstr10 = file_get_contents("http://top.sogou.com/auto/all_".$x.".html");    
  19.     $sgstr11 = file_get_contents("http://top.sogou.com/people/all_".$x.".html");    
  20.     // for循环过滤搜狗  
  21.     for ($i=1; $i<=11; $i++) {  
  22.         preg_match_all('/<p class=\"p1\".*?>.*?<\/p>/ism', ${"sgstr".$i}, $matchestop);  
  23.         preg_match_all('/<p class=\"p3\".*?>.*?<\/p>/ism', ${"sgstr".$i}, $matchesbottom);  
  24.         $strtop = join("\r\n", $matchestop[0]); 
  25.         $strbottom = join("\r\n", $matchesbottom[0]); 
  26.         $sgresult.=$strtop.$strbottom; 
  27.       }  
  28.     $baidustr = mb_convert_encoding(${"baidustr".$x}, 'UTF-8', 'GB2312'); 
  29.     preg_match_all('/<a class=\"list-title\".*?>.*?<\/a>/ism', $baidustr, $matches);  
  30.     $baidustr = join("\r\n", $matches[0]); 
  31.     $sgstrend=$sgresult.$baidustr; 
  32.     $strchuli = strip_tags($sgstrend); 
  33.     $strchulis.=$strchuli; 
  34.   } 
  35.     echo $strchulis; 
  36.     file_put_contents('testyuming/'.date("Y-m-d").'.txt', $strchulis);//存入txt  

这个php脚本运行能获取百度的民生、体育、娱乐、搜狗的七天内3页、电影、电视剧、动漫、小说、音乐、游戏、汽车、人物的实时热点,一运行会在testyuming文件夹生成采集后的txt文本,如果没保存到文件夹,自己新建一个文件夹名为testyuming就行了~方便别人做一些关键词,或者查实时热点。

1.本站资源均为免登陆下载,直接扫码支付即可下载
2.站点支持支付宝扫码支付,更多支付方式联系客服QQ!
3.客服QQ:3013197813,822674928
4.本站大部分下载资源收集于网络,只做学习和交流使用,版权归原作者所有!
5. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
Test玩站网 » 分享一个自动采集获取新闻实时热点的php脚本

常见问题FAQ

玩站小弟QQ没回怎么办?
防止QQ秀逗,大家可以通过:
加QQ群:联系小弟拉你~
发QQ邮箱给玩站小弟[email protected]
扫描右边的微信二维码

发表评论

Test玩站网专注全网精品资源!

QQ咨询 加入Q群
站内大部分资源收集于网络,若资源侵犯了您的合法权益,请联系我们删除!资源仅供参考学习使用,不得使用于非法商业用途,不得违反国家法律。否则后果自负!