Crawl the pricing data from the Bigbakstet website using python

Crawl the pricing data from the Bigbakstet website using python

Using the python code, we can easily crawl the pricing data in minutes.
Here we need some data like BigBasket product ID. This ID is available in your data or the webpage URL.

How to find it on URL?
Please check the below link carefully.


https://www.bigbasket.com/pd/40097083/ariel-detergent-washing-powder-matic-front-load-2-kg/
You can see the number after pd/ this number means that product ID.

So, we got the product ID then we can build our simple crawler using python.

We are using Google Colab for it this is very easy to use and you don’t need to install any library.

We need to import the below libraries

import requests
from bs4 import BeautifulSoup as bs
import pandas as pd

eanCodeLists = [40097083]
# You can add multiple IDs by adding a comma between two IDs

PriceList = []

for items in eanCodeLists:
    urlopen = requests.get('https://www.bigbasket.com/pd/' + str(items)).text
    soup = bs(urlopen, 'lxml')

    # Replace 'IyLvo' with the correct class name by inspecting the webpage's HTML
    PriceName = soup.find("td", {"class": "IyLvo"}).text.strip()
    PriceList.append(PriceName)

table_dict = {'Price': PriceList, 'code': eanCodeLists}
df = pd.DataFrame(table_dict)

# Save the DataFrame to a CSV file
df.to_csv('bb.csv', index=False)

# Download the CSV file if you are using Google Colab
from google.colab import files
files.download('bb.csv')
Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *