Diffbot:“;在分析API时,哪里可以传递统计参数&”;
Diffbot: "Where I can pass stats argument in analyze API?"
我正在使用Diffbot分析API来检测页面类型,我希望得到如下结果这个
{"stats":{"times": {"docParseTime":0,"docGlobalsTime":0,"fetchAndRenderTime":586,"typeTime":0},"fromCache":true,"types":{"recipe":0,"discussion":0,"audio":0,"error":0,"location":0,"faq":0,"image":0,"job":0,"download":0,"game":0,"product":0,"frontpage":0,"document":1,"article":0,"event":0,"chart":0,"serp":0,"reviewslist":0,"video":0,"profile":0}},"request":{"pageUrl":"http://www.irs.gov/pub/irs-pdf/fw4.pdf","api":"analyze","version":3,"options":["stats"]},"type":"other","objects":[]}
但目前我觉得这个
{"request":{"pageUrl":"http://static.nfl.com/static/content/public/image/rulebook/pdfs/2013%20-%20Rule%20Book.pdf","api":"analyze","version":3},"type":"other","objects":[]}
我必须在请求中传递"stats"参数。但在有要求的地方,我可以通过这个论点。谢谢,
嗨,我得到了它,这是解决方案,只需自定义Diffbot lib文件或在文件中写入它就可以了,这是代码
var diffbot = new Diffbot('xxxxxxxxxxxxxxxxx');
diffbot.analyze({
uri: "http://www.visitcalifornia.in/media/pages/getting_around/maps/ORANGE-COUNTY.pdf",
html: true,
comments: true,
stats: true
}, function(err, response) {
}
这是自定义库代码
Diffbot.prototype.analyze = function (options, callback) {
for (var i in options) {
this[i] = options[i];
}
var options = this;
// support 'url'
if (options.url) {
options.uri = options.url;
delete options.url;
}
if (!options.uri) {
throw new Error("the URI is required.");
}
var diffbot_url = "http://api.diffbot.com/v3/analyze?token=" + this.token + "&url=" + encodeURIComponent(options.uri)+"&fields=stats";
if (options.stats) {
diffbot_url += "&stats=1";
}
request({uri: diffbot_url}, function(error, response, body) {
if (error) {
callback(error, undefined);
} else {
callback(false, JSON.parse(body));
}
});
}
它起到了魅力的作用!
相关文章:
- 函数参数中的数据与指定变量之间的任何性能差异
- 使用Express捕获参数
- 参数变量出现ngTable指令问题
- AngularJS:我可以跳过函数参数回调吗
- 如何使用skip参数使用angular ui引导进行服务器端分页
- 要求未定义JS回调参数
- 我的jQuery插件参数没有正确启动,遇到了问题
- 获取@ResponseBody的一部分作为主干和Spring MVC控制器之间的参数
- jquery设置为使用参数运行
- Javascript”;类“;带有参数的扩展
- 为什么grunt contrib connect的中间件选项的第三个参数是未定义的
- 函数未将值作为参数传递
- 如何将参数传递到angularJs中的工厂
- JS:检查URL中的参数,然后迭代一个参数为var的函数
- 正在传递JSONP标头's数据参数到另一个文件中的AJAX请求
- MVC 3页面导航和使用javascript传递参数
- 从查询字符串参数推断出正确的数据类型
- 传递包含'%的参数'在URL中
- Diffbot:“;在分析API时,哪里可以传递统计参数&”;
- 统计查询字符串中包含的参数个数