Uninews
Uninews is a universal news scraper written in Rust. It downloads a news article from a given URL, cleans the HTML content, and then uses CloudLLM (via OpenAI) to convert the content into Markdown format. The final output is a JSON object with the article's title, the Markdown-formatted content, and a featured image URL.
Features
- Scraping & Cleaning: Extracts the main content of a news article by targeting the
<article>tag (or falling back to<body>) and removing unwanted elements. - Markdown Conversion: Uses gpt-4o through the CloudLLM rust API to convert the cleaned HTML content into nicely formatted Markdown.
- Reusable Library: The
universal_scrapefunction is exposed for easy integration into other Rust projects.
Installation
You need to have Rust and Cargo installed on your system.
If you do have Rust installed, follow these steps:
- Install Uninews:
If you don't have Rust installed, follow these steps:
-
Install Rust:
On Unix/macOS:
| -
Verify Installation
-
Clone the Project:
-
Build & Install the Project:
- Run it in the command line:
# make sure to either export the OPEN_AI_SECRET token before running it
# or you can set it on the same statement and not export it
OPEN_AI_SECRET=sk-xxxxxxxxxxxxxxxxxxxxxxxxxx
uninews --help
Usage: uninews <URL>
Arguments:
<URL> The URL of the news article to scrape
Options:
-h, --help Print help
-V, --version Print version
- ** Integrating it with your rust project **
using ;
// If you have your OPEN_AI_SECRET loaded by some other means
// than from ENV, you can set it like this
// std::env::set_var("OPEN_AI_SECRET", my_open_ai_secret);
let post = universal_scrape.await;
if !post.error.is_empty
// Print the title and Markdown-formatted content.
println!;