https://github.com/postlight/mercury-rs
The official Rust client for the Mercury Parser
https://github.com/postlight/mercury-rs
async client mercury parser
Last synced: 4 months ago
JSON representation
The official Rust client for the Mercury Parser
- Host: GitHub
- URL: https://github.com/postlight/mercury-rs
- Owner: postlight
- License: apache-2.0
- Created: 2017-10-23T18:13:52.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-26T00:26:14.000Z (almost 8 years ago)
- Last Synced: 2025-06-02T15:44:16.150Z (4 months ago)
- Topics: async, client, mercury, parser
- Language: Rust
- Homepage: https://mercury.postlight.com
- Size: 28.3 KB
- Stars: 17
- Watchers: 8
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# mercury-rs
[](https://circleci.com/gh/postlight/mercury-rs/tree/master)
The official Rust client for the [Mercury Parser](https://mercury.postlight.com/web-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.
* [Documentation](https://docs.rs/mercury)
* [Homepage](https://mercury.postlight.com)
* [Examples](./examples)## Installation
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](https://mercury.postlight.com/web-parser).
Add this to your `Cargo.toml`:
```toml
[dependencies]
futures = "0.1"
mercury = "0.1"
tokio-core = "0.1"
```Add this to your `main.rs`:
```rust
extern crate futures;
extern crate mercury;
extern crate tokio_core;
```## Usage
```rust
// Create a new event loop with tokio.
let mut core = Core::new()?;// 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(&core.handle(), key)?;// The parse method returns a Future that will resolve to a parsed Article.
let resp = client.parse("https://example.com").inspect(|article| {
println!("{:#?}", article);
});// Block the current thread until the future completes.
core.run(resp)?;
```*Additional examples can be found [here](./examples).*
## License
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.