`

前嗅ForeSpider脚本教程-链接抽取:自定义链接写脚本

阅读更多

场景:当采集的链接不存在于任何位置,或者想要采集自定义的链接。

示例:天猫商品评论的链接。

商品评论的链接不在源码中,只能自己拼接评论链接。点击评论翻页,观察翻页规律。

取其中某一链接地址在网页中查看请求返回信息。删除个别不一致的请求参数,观察结果是否变化。可得到最简链接地址。

https://rate.tmall.com/list_detail_rate.htm?itemId=566879444630&spuId=950725258&sellerId=134363478&order=3¤tPage=2&append=0&content=1&tagId=&posi=&picture=&groupId=&ua=&callback=

脚本实例:

 

for(int i=0;i<10;i++){//取10页评论
url u;
u.title = “第+i+”页评论”;
u.urlname = “https://rate.tmall.com/list_detail_rate.htm?itemId=566879444630&spuId=950725258&sellerId=134363478&order=3¤tPage=”+i+”&append=0&content=1&tagId=&posi=&picture=&groupId=&ua=&callback=”;  //第i页的评论链接地址
u.entryid = CHANN.id;
u.tmplid = 2;
RESULT.AddLink(u);
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics