Table Of Content
    Let's Talk About Your Data Needs

    Tell us what data you need, and we'll help you find the right solution.

    Contact Us
    Back to Blog

    How to Scrape Flipkart Product Data with Beautiful Soup and Python?

    how-to-scrape-flipkart-product-data-with-beautiful-soup-and-python
    Category
    E-commerce & Retail
    Publish Date
    May 14, 2021
    Author
    Scraping Intelligence

    In this blog, we will see how we scrape Flipkart product data scraping using BeautifulSoup and Python in an elegant and simple manner.

    The target of this blog is to get started on practical problem resolving while holding it easy so that you get practical and familiar outcomes as quick as feasible.

    The first thing we require to do is install Python 3. If you don’t than you need to install Python 3 before the process.

    pip3 install beautifulsoup4

    Once it is installed you require to type in and open the editor:

    # -*- coding: utf-8 -*-
    from bs4 import BeautifulSoup
    import requests

    Now visit the Flipkart List page and examine what information we can acquire

    Not let’s get back to code. Let’s get data and try to imagining we are a browser like this:

    # -*- coding: utf-8 -*-
    from bs4 import BeautifulSoup
    import requests
    import reheaders = {‘User-Agent’:’Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9′}
    url = ‘https://www.flipkart.com/mobile-accessories/power-banks/pr?sid=tyy,4mr,fu6&otracker=categorytree&otracker=nmenu_sub_Electronics_0_Power Banks’response=requests.get(url,headers=headers)soup=BeautifulSoup(response.content,’lxml’)

    You can save this by scrapeFlipkart.py

    python3 scrapeFlipkart.py

    You will able to see the full HTML page.

    Now, utilize CSS selectors to acquire data you need. To perform that you need to go to open chrome review the tool.

    We observe that all the particular product information is included with the quality data-id. You also observe that the feature worth is some rubbish and it always keeps changing. But the hint is the occurrence of the data-id features itself. The whole thing we require. So let’s scrap that.

    # -*- coding: utf-8 -*-
    from bs4 import BeautifulSoup
    import requests
    import reheaders = {‘User-Agent’:’Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9′}
    url = ‘https://www.flipkart.com/mobile-accessories/power-banks/pr?sid=tyy,4mr,fu6&otracker=categorytree&otracker=nmenu_sub_Electronics_0_Power Banks’response=requests.get(url,headers=headers)soup=BeautifulSoup(response.content,’lxml’)for item in soup.select(‘[data-id]’):
    try:
    print(‘—————————————-‘)
    print(item)
    except Exception as e:
    #raise e
    b=0

    This will print the content in every of the ampoules that clutch the product information.

    Now get back to work for every field we require. This is interesting because Flipkart HTML has no significant CSS programs we can utilize. So we will route to some actions that is dependable.

    print(item.select(‘a img’)[0][‘alt’])
    print(item.select(‘a’)[0][‘href’])

    The other lines beyond give us the URL of the list.

    But we can utilize the *= operator to choose whatever which has the term product rating like this:

    print(item.select(‘[id*=productRating]’)[0].get_text().strip())

    Extracting the price is more interesting as it do not contain visible ID or class name as a hint to get. But every time it has the exchange denominator ₹ in it.

    prices = item.find_all(text=re.compile(‘₹’))
    print(prices[0])

    We do similar to acquire the discount rates.

    discounts = item.find_all(text=re.compile(‘off’))
    print(discounts[0])
    
    Put everything together
    
    # -*- coding: utf-8 -*-
    from bs4 import BeautifulSoup
    import requests
    import reheaders = {‘User-Agent’:’Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9′}
    url = ‘https://www.flipkart.com/mobile-accessories/power-banks/pr?sid=tyy,4mr,fu6&otracker=categorytree&otracker=nmenu_sub_Electronics_0_Power Banks’response=requests.get(url,headers=headers)soup=BeautifulSoup(response.content,’lxml’)for item in soup.select(‘[data-id]’):
    try:
    print(‘—————————————-‘)
    #print(item)
    print(item.select(‘a img’)[0][‘alt’])
    print(item.select(‘a’)[0][‘href’])         print(item.select(‘[id*=productRating]’)[0].get_text().strip())
    prices = item.find_all(text=re.compile(‘₹’))
    print(prices[0])        discounts = item.find_all(text=re.compile(‘off’))
    print(discounts[0])     except Exception as e:
    #raise e
    b=0

    If you need to measure the scraping speed and don’t need to fix up your particular infrastructure, then you can utilize our Flipkart product data crawler to effortlessly scrape millions of URLs at great speed from our crawlers.

    If you are looking for the best Flipkart Data Scraping Services, then you can contact Scraping Intelligence for all your queries.


    About the Author


    Scraping Intelligence

    Scraping Intelligence Editorial Team is a collective of data specialists, analysts, and researchers with expertise in web scraping, data extraction, and market intelligence. The team produces well-researched guides, actionable insights, and industry-focused resources that help businesses unlock the value of data and make informed, strategic decisions.

    Latest Blog

    Explore our latest content pieces for every industry and audience seeking information about data scraping and advanced tools.

    How-Web-Scraping-is-Used-to-Extract-Hotel-Data-Without-Code
    Hotel & Travel
    20 Nov 2026

    How Web Scraping is Used to Extract Hotel Data Without Code?

    Learn how to extract hotel data without coding. Discover no-code scraping methods to collect hotel prices, ratings, reviews, and competitor insights.

    ethical-web-scraping-for-enterprises
    Services
    16 Nov 2026

    Ethical Web Scraping for Enterprises: Data Sourcing, Compliance, and Risk Management

    Explore ethical web scraping for enterprises, covering data sourcing, privacy laws, compliance risks, and strategies for responsible data collection at scale.

    top-web-scraping-companies
    Services
    06 Nov 2026

    Top 10 Web Scraping Companies: Features, Services & Pricing

    Looking for a web scraping company? Compare 10 top providers, from managed data services to APIs and no-code tools, by pricing, features, and scalability.

    property-finder-data-scraping
    Real Estate
    03 Nov 2026

    Property Finder Scraping for Dubai & UAE Real Estate Data

    Explore Property Finder data scraping to collect UAE property prices, listings, locations, and rental trends for smarter market research and investment analysis.