flipkart_scraper

Crates.ioflipkart_scraper
lib.rsflipkart_scraper
version0.2.9
sourcesrc
created_at2023-10-07 18:47:26.092515
updated_at2024-08-14 06:00:01.841324
descriptionScrape Flipkart product details
homepage
repositoryhttps://github.com/dvishal485/flipkart-scraper
max_upload_size
id996537
size73,945
Vishal Das (dvishal485)

documentation

README

flipkart-scraper

Crates.io NPM Version Documentation GitHub issues Telegram GitHub license

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.


Features

  • Does not require any client id/secret or any other authorisation

  • Fetch product details from URL of product which includes

    • Product Name
    • Current and Original Price
    • User Rating
    • Stock avalibility
    • Flipkart Assured Product
    • Share URL (More presentable URL)
    • Seller Information (Seller Name and Rating)
    • Product Thumbnails
    • Highlights
    • Available Offers
    • Product Specifications
  • Search product on Flipkart from its query, giving the following details

    • Product Name
    • Product Link
    • Product Thumbnail
    • Current Price of Product
    • Original Price of Product

Example Usage

Navigate to examples for basic use cases.

NPM Package

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

    1. Fetch the product page using fetch API or axios or any other networking module.

    2. 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

    1. Fetch the search page (https://www.flipkart.com/search?q={query}) using fetch API or axios or any other networking module.
    2. Parse the webpage content using the library.
    import flipkart_scraper from "@dvishal485/flipkart_scraper";
    
    const search_result = flipkart_scraper.parse_search_results(product_webpage);
    console.log(search_result);
    

Rust Crate

  • 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(())
    }
    

License

This Project is licensed under GNU General Public License (GPL-3.0).


Commit count: 74

cargo fmt