leejunji 发表于 2013-4-16 09:54:15

火车采集器v7版新浪评论采集插件~~~~~~~

这个插件是对多页中的第一个页面进行了分析,获取到分页总数,然后生成了分页让采集器下载,涉及的代码为

      public List<string> GetPagesUrl(int level, string pageurl, string html, string pagesStyle, string pagesCombine)
      {
            List<string> urls = new List<string>();
            //"show": 127}, http://comment5.news.sina.com.cn/page/info?format=js&jsvar=pagedata&channel=gn&newsid=1-1-24331859&group=0&page=1&list=all&sort=0,
http://news.sina.com.cn/c/2012-04-26/061224331859.shtml


            if (level == 1 && pageurl.Contains("page=1&"))
            {
            string sign="show\": ";
            int pos = html.IndexOf(sign);
            if (pos > 0)
            {
                  int pos2 = html.IndexOf("}", pos);
                  if (pos2 > 0)
                  {
                      int count = int.Parse(html.Substring(pos + sign.Length, pos2 - pos - sign.Length));
                      count = (int)Math.Ceiling((double)count / 20);
                      for (int i = 2; i < count + 1; i++)
                      {
                        urls.Add(pageurl.Replace("page=1", "page=" + i.ToString()));
                      }
                  }
            }
            }
            return urls;
      }


public bool UseGetPagesUrl
      {
            get { return true; }
      }


附件下载地址和说明参考地址:http://board.locoy.com/?post=124

mzs777 发表于 2013-4-23 13:58:59

谢谢了下载看看正需要这个
页: [1]
查看完整版本: 火车采集器v7版新浪评论采集插件~~~~~~~