2014-10-20 1 views
0

나는 페이지 유형을 검출 API를 분석 Diffbot를 사용하고 난 이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":[]} 

'통계'인수와 같은 결과를 원하는 요청하십시오. 그러나 요청에 따라이 인수를 전달할 수 있습니다. 감사합니다,

답변

0

안녕 내가 여기있어하고 그냥 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)); 
    } 
    }); 
} 

그것은 매력으로 작동합니다!

관련 문제