Crates.io | flipkart_scraper |
lib.rs | flipkart_scraper |
version | 0.2.9 |
source | src |
created_at | 2023-10-07 18:47:26.092515 |
updated_at | 2024-08-14 06:00:01.841324 |
description | Scrape Flipkart product details |
homepage | |
repository | https://github.com/dvishal485/flipkart-scraper |
max_upload_size | |
id | 996537 |
size | 73,945 |
Scrapes product details and searches on Flipkart.
Disclaimer: I am not affiliated or linked to flipkart in any way. This repository is an exploratory project and not meant for commercial use.
Does not require any client id/secret or any other authorisation
Fetch product details from URL of product which includes
Search product on Flipkart from its query, giving the following details
Navigate to examples for basic use cases.
NPM Package can be used to parse the contents of webpage to return a valid JSON object response.
Refer to examples/js_demo example for a quick overview of using the npm package.
The package can be installed with npm
npm i @dvishal485/flipkart_scraper
Fetching Product Details
Fetch the product page using fetch API or axios or any other networking module.
Parse the webpage content using the library.
import flipkart_scraper from "@dvishal485/flipkart_scraper";
const product_details = flipkart_scraper.parse_product_details(product_webpage);
console.log(product_details);
Searching Products
https://www.flipkart.com/search?q={query}
) using fetch API or axios or any other networking module.import flipkart_scraper from "@dvishal485/flipkart_scraper";
const search_result = flipkart_scraper.parse_search_results(product_webpage);
console.log(search_result);
Fetching Product Details
Snippet to fetch and print product details from Flipkart using product's URL.
use std::error::Error;
use flipkart_scraper::{ProductDetails, Url};
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let url = "https://www.flipkart.com/samsung-galaxy-f13-waterfall-blue-64-gb/p/itm583ef432b2b0c";
let details = ProductDetails::fetch(Url::parse(url)?).await;
println!("{:#?}", details);
Ok(())
}
Searching Products
Snippet to search a particular product on Flipkart using a given query.
use flipkart_scraper::ProductSearch;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let query = "samsung washing machine";
let details = ProductSearch::search(query.into()).await;
if let Ok(s) = details {
println!("{:#?}\n\nTotal {} search results.", s, s.results.len());
} else {
println!("{}", details.unwrap_err());
}
Ok(())
}
This Project is licensed under GNU General Public License (GPL-3.0).