宇宙主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

欧基零壹微头条IP归属甄别会员请立即修改密码
查看: 2361|回复: 2

[Windows VPS] 求助一个采集评论文件,运行之后只能采集到第一页!

[复制链接]
发表于 2012-11-7 23:38:21 | 显示全部楼层 |阅读模式
求助一个采集评论文件,运行之后只能采集到第一页!

跳转到第二页就出现
502 Bad Gateway nginx/1.2.4
  1. <?php
  2. header("Content-Type: text/html; charset=utf-8");
  3. $var_array = require_once './config.php';  
  4. extract($var_array, EXTR_PREFIX_SAME, "new");
  5. //--------数据库类---------
  6. $dbconn=mysql_connect($db_host,$db_user,$db_pwd);
  7. mysql_query("SET NAMES utf8",$dbconn);
  8. mysql_select_db($db_name);
  9. //--------------------------
  10. function curl_string ($url,$user_agent,$proxy){
  11.         $ch = curl_init();
  12.         curl_setopt ($ch, CURLOPT_PROXY, $proxy);
  13.         curl_setopt ($ch, CURLOPT_URL, $url);
  14.         curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
  15.         curl_setopt ($ch, CURLOPT_HEADER, 1);
  16.         curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  17.         curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
  18.         curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
  19.         $result = curl_exec ($ch);
  20.         curl_close($ch);
  21. return $result;
  22. }
  23. //---
  24.                 function steal($ZQQ_webfile,$start,$end,$lt,$gt){
  25.                         $str = explode($start,$ZQQ_webfile); $str = explode($end,$str[1]); $strs = $str[0];
  26.                         if($lt){ $strs = $start.$strs; } if($gt){ $strs = $strs.$end; }
  27.                         return($strs);
  28.                 }
  29. //-------------------------------
  30. $ip_long = array(
  31.             array('607649792', '608174079'), //36.56.0.0-36.63.255.255
  32.             array('1038614528', '1039007743'), //61.232.0.0-61.237.255.255
  33.             array('1783627776', '1784676351'), //106.80.0.0-106.95.255.255
  34.             array('2035023872', '2035154943'), //121.76.0.0-121.77.255.255
  35.             array('2078801920', '2079064063'), //123.232.0.0-123.235.255.255
  36.             array('-1950089216', '-1948778497'), //139.196.0.0-139.215.255.255
  37.             array('-1425539072', '-1425014785'), //171.8.0.0-171.15.255.255
  38.             array('-1236271104', '-1235419137'), //182.80.0.0-182.92.255.255
  39.             array('-770113536', '-768606209'), //210.25.0.0-210.47.255.255
  40.             array('-569376768', '-564133889'), //222.16.0.0-222.95.255.255
  41. );
  42. $rand_key = mt_rand(0, 9);
  43. //$ip= long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));
  44. $page=$_GET['page'];
  45. if(!is_numeric($page)){
  46.         $url_page = "http://www.mtime.com/review/shortcomment/index.html";
  47.         $page = 1;
  48. }else{
  49. $url_page = "http://www.mtime.com/review/shortcomment/index-".$page.".html";
  50. }
  51. $user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; en) operea ";
  52. $proxy = "";
  53. $xhtml = curl_string($url_page,$user_agent,$proxy);

  54. $xmain = steal($xhtml,'<!--评论列表-->        <ul>','</ul>',false,false);
  55. if($xmain!="")
  56. {
  57.         $xlist = explode('</li>',$xmain);
  58.         for($i = 0;$i< count($xlist)-1;$i++)
  59.         {
  60.         $pingcon = steal($xlist[$i],'<p class=" c_666">',"</p>",false,false);
  61.         $pingtv = steal($xlist[$i],'target="_blank">《',"》",false,false);
  62.         $pingtime = steal($xlist[$i],'<span class="fr c_666">',"</span>",false,false);
  63.         $pingtime = $pingtime.':'.rand(00,60);
  64.         $pingtime = ereg_replace(":",":",$pingtime);
  65.         $pingtime = strtotime($pingtime);
  66. $videoid=0;
  67. $result=mysql_query("select id,cid from ".$db_prefix."video where status=1 and title like '%".$pingtv."%'");
  68.   while($rs=mysql_fetch_object($result))
  69.   {
  70.   $videoid=$rs->id;
  71.   $videocid=$rs->cid;
  72.         if($videocid > 7 && $videocid < 15){
  73.         $videocid = 1;
  74.         }
  75.         if($videocid > 14 && $videocid < 22){
  76.         $videocid = 2;
  77.         }
  78.   }
  79.                                         $ok="<font color=red>跳过</font>";
  80.                 if($videoid>0)
  81.                         {
  82.                                 $pingid=0;
  83.                                 $pingresult=mysql_query("select id from ".$db_prefix."comment where did=".$videoid." and content='".$pingcon."'");
  84.                                 while($rrs=mysql_fetch_object($pingresult))
  85.                                 {
  86.                                 $pingid=$rrs->id;
  87.                                 }
  88.                                         if($pingid==0)
  89.                                         {
  90.                                                 mysql_query("insert into ".$db_prefix."comment (did,mid,uid,content,up,down,ip,addtime,status) values(".$videoid.",1,1,'".$pingcon."',".rand(0,20).",".rand(0,5).",'".long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]))."','".$pingtime."',1)");
  91.                                         $ok="<font color=blue>添加</font>";
  92.                                         }
  93.                         }

  94.         echo "[$pingtv (id=$videoid)] $pingcon $ok<br/>";
  95.                
  96.         }
  97. if($page<10){
  98. echo "3秒后采集第".($page + 1) ."页<script>setTimeout("lt()",3000);</script>";
  99. }
  100. }
  101. ?>
  102. <script language="javascript">   
  103. function lt(){
  104.      window.location.href="?page=<?php echo $page+1 ?>";   
  105.   }   
  106. </script>
复制代码
发表于 2012-11-7 23:39:20 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
 楼主| 发表于 2012-11-7 23:42:00 | 显示全部楼层
Administrator 发表于 2012-11-7 23:39
改程序还不如自己写个来的方便

  那是你们技术流
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|兜哪儿主机交流论坛

GMT+8, 2024-9-21 01:49 , Processed in 0.192516 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表