Sunday 15 May 2011

javascript - Diffbot: "Where I can pass stats argument in analyze API?" -



javascript - Diffbot: "Where I can pass stats argument in analyze API?" -

i using diffbot analyze api detecting page type , want result this

{"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":[]}

but getting this

{"request":{"pageurl":"http://static.nfl.com/static/content/public/image/rulebook/pdfs/2013%20-%20rule%20book.pdf","api":"analyze","version":3},"type":"other","objects":[]}

i have pass 'stats' argument in request. in request, can pass argument. thanks,

hi got , here solution, customize diffbot lib file or write in file you, , here code

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) { }

and here customize library code

diffbot.prototype.analyze = function (options, callback) { (var in options) { this[i] = options[i]; } var options = this; // back upwards 'url' if (options.url) { options.uri = options.url; delete options.url; } if (!options.uri) { throw new error("the uri 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)); } }); }

it works charm!

javascript node.js diffbot

No comments:

Post a Comment