Web Scraping using Python

Neel shah
3 min readAug 3, 2021

--

Introduction

The internet is an absolutely massive source of data — data that we can access using web scraping and Python!

In fact, web scraping is often the only way we can access data. There is a lot of information out there that isn’t available in convenient CSV exports or easy-to-connect APIs. And websites themselves are often valuable sources of data — consider, for example, the kinds of analysis you could do if you could download every post on a web forum.

To access those sorts of on-page datasets, we’ll have to use web scraping.

In today’s competitive world everybody is looking for ways to innovate and make use of new technologies. Web scraping (also called web data extraction or data scraping) provides a solution for those who want to get access to structured web data in an automated fashion. Web scraping is useful if the public website you want to get data from doesn’t have an API, or it does but provides only limited access to the data.

In this article, we are going to shed some light on web scraping, here’s what you will learn:

What is web scraping?

Web scraping is the process of collecting structured web data in an automated fashion. It’s also called web data extraction. Some of the main use cases of web scraping include price monitoring, price prediction, news monitoring, price generation, and market research among many others.

In general, web data extraction is used by people and businesses who want to make use of the vast amount of publicly available web data to make smarter decisions.

If you’ve ever copy and pasted information from a website, you’ve performed the same function as any web scraper, only on a microscopic, manual scale. Unlike the mundane, mind-numbing process of manually extracting data, web scraping uses intelligent automation to retrieve hundreds, millions, or even billions of data points from the internet’s seemingly endless frontier.

The basics of web scraping

It’s extremely simple, in truth, and works by way of two parts: a web crawler and a web scraper. The web crawler is the horse, and the scraper is the chariot. The crawler leads the scraper, as if by hand, through the internet, where it extracts the data requested.

The web scraping process

If you do it yourself

This is what a general web scraping process looks like:

  1. Identify the target website
  2. Collect URLs of the pages where you want to extract data from
  3. Make a request to these URLs to get the HTML of the page
  4. Use locators to find the data in the HTML
  5. Save the data in a JSON or CSV file or some other structured format

Web Scrapping Example

  1. Find the URL that you want to scrape

In this blog we are going to scrape Flipkart website for product info.

https://www.flipkart.com/search?q=phone&otracker=search&otracker1=search&marketplace=FLIPKART&as-show=on&as=off

We will scrap data from above URL.

2. Inspecting the Page and find data that you want

Right click on website and click on inspect.

Find tag of data that you want to scrape.

write the code

Output:

Thank You…

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Neel shah
Neel shah

Written by Neel shah

Information Technology Graduate, CHARUSAT UNIVERSITY,2022

No responses yet

Write a response