Crates.io | google_search_rs |
lib.rs | google_search_rs |
version | 0.1.0 |
source | src |
created_at | 2024-09-26 17:12:16.653171 |
updated_at | 2024-09-26 17:12:16.653171 |
description | A crate for scraping Google search results using headless Chrome. |
homepage | |
repository | https://github.com/ChiragChauhan4579/google_search_rs |
max_upload_size | |
id | 1387843 |
size | 4,501,461 |
google_search_rs allows you to scrape Google search results programmatically using a headless browser, extract relevant information (titles, URLs, and snippets), and store the results in a polars::DataFrame or CSV file.
Headless Browsing: Automates browser interactions using headless_chrome. Google Search Scraping: Extracts titles, URLs, and snippets from search results. Multiple Pages: Scrapes multiple pages of search results, if available. Data Storage: Returns the scraped data as a Polars DataFrame and optionally saves it as a CSV file.
google_search_rs = "0.1.0"
use google_search_rs::search;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let search_query = "Rust Programming Language";
let max_pages = 10;
// To only retrieve a dataframe
// let df = search(search_query,max_pages,None)?;
// To save the results in a csv
let df = search(search_query,max_pages,Some("results.csv"))?; // This will scrape the first ten pages of Google search results for "Rust Programming Language" and save the results in a CSV file called results.csv.
println!("{:?}",df);
Ok(())
}
The extracted search results will contain the following columns: Title: The title of the search result. URL: The URL of the search result. Snippet: A brief description or snippet from the search result.
This project is licensed under the MIT License.