208
火车采集器
火车采集器v7版新浪评论采集插件
火车采集器v7版新浪评论采集插件
作者:小文 发布于:2012-5-15 20:41 Tuesday 分类:免费插件
这个插件是对多页中的第一个页面进行了分析,获取到分页总数,然后生成了分页让采集器下载,涉及的代码为
public List<string> GetPagesUrl(int level, string pageurl, string html, string pagesStyle, string pagesCombine){
List<string> urls = new List<string>();
//"show": 127}, https://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,
https://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; }
}
规则请在附件中下载
附件下载:
新浪评论.7z 4.19KB
标签: 新浪
评论:
最后更新:2017-05-09 01:05:59