Crate mercury [−] [src]
The official Rust client for the Mercury Parser.
With just one API request, Mercury takes any web article and returns only the relevant content — headline, author, body text, relevant images and more — free from any clutter. It’s reliable, easy-to-use and free.
Usage
The examples in this document assume you already have a Mercury Parser API key. If you do not already have one, you can sign up here.
Installation
Add this to your Cargo.toml
:
[dependencies]
futures = "0.1"
mercury = "0.1"
tokio-core = "0.1"
Example
Additional examples can be found on GitHub.
// Create a new event loop with tokio. let mut core = Core::new()?; let handle = core.handle(); // Load your API key from the environment. let key = env::var("MERCURY_API_KEY")?; // Pass a handle to the event loop and the API key to the Mercury constructor. let client = Mercury::new(&handle, key)?; // The parse method returns a Future that will resolve to a parsed Article. let future = client.parse("https://example.com").inspect(|article| { println!("{:#?}", article); }); // Block the current thread until the future completes. core.run(future)?;
Reexports
pub use error::Error; |
Modules
error |
Types representing errors that can occur. |
Structs
Article |
Structured data, deserialized from an API response. |
Mercury |
A client used to make requests to the Mercury Parser. |
Response |
Enums
TextDirection |
Represents the text direction of parsed body content. |