Struct diffbot::Diffbot [] [src]

pub struct Diffbot {
    // some fields omitted
}

Diffbot API client.

Example

let diffbot = Diffbot::v3("token");
let result = diffbot.call(API::Analyze, "http://diffbot.com");

Methods

impl Diffbot

fn new<S: ToString>(token: S, version: u8) -> Self

Returns a Diffbot client that uses the given token and version.

Valid versions: 1, 2, 3.

fn v1<S: ToString>(token: S) -> Self

Convenient method to use a v1 client.

fn v2<S: ToString>(token: S) -> Self

Convenient method to use a v2 client.

fn v3<S: ToString>(token: S) -> Self

Convenient method to use a v3 client (recommended).

fn call(&self, api: API, target_url: &str) -> DiffbotResult

Makes an API call without extra options.

Just calls call_with_options with an empty option list.

fn call_with_options<S: ToString>(&self, api: API, target_url: &str, options: &[(S, S)]) -> DiffbotResult

Makes an API call

Runs target_url through the diffbot endpoint specified by api. Add each (key,value) pair in options to the query string. Read the diffbot documentation for information on supported values.

Example

diffbot.call_with_options(API::Article,
                          "http://diffbot.com",
                          &[("paging", "false")])

fn list_crawls(&self) -> DiffbotResult

List existing crawls.

fn post_body(&self, api: API, target_url: &str, body: &[u8]) -> DiffbotResult

Post an entire html body to the API, without extra options.

See call_with_options for information on the arguments.

target_url here is the URL the page would have. It doesn't have to be accessible, but will be used when resolving links.

Example

let body = b"<html>...</html>";
diffbot.post_body(API::Article,
                  "http://my.website.com",
                  body)

fn post_body_with_options<S: ToString>(&self, api: API, target_url: &str, body: &[u8], options: &[(S, S)]) -> DiffbotResult

Posti an entire html body to the API.

See call_with_options for information on the arguments.

target_url here is the URL the page would have. It doesn't have to be accessible, but will be used when resolving links.

fn search(&self, col: &str, query: &str) -> DiffbotResult

Run a search in a diffbot collection without extra options.

Use col = GLOBAL-INDEX for the global search collection.

Example

diffbot.search("GLOBAL-INDEX", "diffbot")

fn search_with_options<S: ToString>(&self, col: &str, query: &str, options: &[(S, S)]) -> DiffbotResult

Run a search in a diffbot collection.

Use col = GLOBAL-INDEX for the global search collection.

fn bulk<S: AsRef<str> + Borrow<str>>(&self, name: &str, api: API, urls: &[S]) -> DiffbotResult

Starts a bulk job.

Starts a bulk job called name on the given url list, using api_url on each.

fn bulk_with_options<S: AsRef<str> + Borrow<str>>(&self, name: &str, api: API, urls: &[S], options: &[(S, S)]) -> DiffbotResult

Starts a bulk job with extra options.

Give options a list of (key, value) pairs.

Example

diffbot.bulk_with_options("my_bulk_job", API::Analyze,
                         &["http://my.first.page.com",
                           "https://my.second.page.com"],
                         &[("repeat", "7.0"),
                           ("notifyEmail", "me@example.com")])

fn get_bulk(&self, name: &str) -> DiffbotResult

Retrieves the result from a bulk job

fn crawl<S: AsRef<str> + Borrow<str>>(&self, name: &str, api: API, seeds: &[S]) -> DiffbotResult

Starts a crawl job.

fn crawl_with_options<S: AsRef<str> + Borrow<str>>(&self, name: &str, api: API, seeds: &[S], options: &[(S, S)]) -> DiffbotResult

Starts a crawl job with extra options.

Give options a list of (key, value) pairs.

Example

diffbot.crawl_with_options("my_crawl_job", API::Analyze,
                           &["http://my.first.page.com",
                             "https://my.second.page.com"],
                           &[("repeat", "7.0"),
                             ("maxHops", "3")])

fn get_crawl(&self, name: &str) -> DiffbotResult

Retrieves the result from a crawl job.