没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
/*使用 javascript 编写的爬虫源码,用于爬取京东商城上的商品信息和评论。
代码粘贴到神箭手云爬虫平台(http://www.shenjianshou.cn/)上就可以直接跑了,不需要安
装编译环境。要爬取其他网站,可以更改源码即可。
代码执行具体步骤请参考:
https://github.com/ShenJianShou/crawler_samples/blob/master/%E5%A6%82%E4%BD%95%E6
%89%A7%E8%A1%8C%E6%A0%B7%E4%BE%8B%E4%BB%A3%E7%A0%81.txt
*/
var keyword = "d3.js";//@input(keyword, 查询关键字, 爬取该关键字搜索出来的京东商品)
var comment_count = 100;//@input(comment_count, 爬取的评论数, 最多爬取多少条评论)
var page_count = comment_count / 10;
keyword = keyword.trim();
var scanUrls = [];
scanUrls.push("http://search.jd.com/Search?keyword="+keyword.replace(/ /g,
"+")+"&enc=utf-8&qrst=1&rt=1&stop=1&book=y&vt=2&page=1&s=1&click=0");
var helperUrlRegexes = [];
helperUrlRegexes.push("http://search\.jd\.com/Search\?keyword="+keyword.replace(/ /g,
"\+").replace(/\./g,
"\.")+"&enc=utf-8&qrst=1&rt=1&stop=1&book=y&vt=2&page=\d+&s=1&click=0");
var configs = {
domains: ["search.jd.com","item.jd.com","club.jd.com"],
scanUrls: scanUrls,
contentUrlRegexes: ["http://item\.jd\.com/\d+.html"],
helperUrlRegexes: helperUrlRegexes,
fields: [
{
// 第一个抽取项
name: "title",
selector: "//div[@id='name']/h1",
required: true
},
{
// 第一个抽取项
name: "productid",
selector: "//div[contains(@class,'fl')]/span[2]",
required: true
},
{
name: "comments",
selector: "//div[@id='comment-pages']/span",
repeated: true,
资源评论
qq_34986051
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功