Open In App
Related Articles

Build a COVID19 Vaccine Tracker Using Python

Improve Article
Improve
Save Article
Save
Like Article
Like

As we know the world is facing an unprecedented challenge with communities and economies everywhere affected by the COVID19. So, we are going to do some fun during this time by tracking their vaccine. Let’s see a simple Python script to improve for tracking the COVID19 vaccine.

Modules Needed

  • bs4: Beautiful Soup(bs4) is a Python library for pulling data out of HTML and XML files. This module does not comes built-in with Python. To install this type the below command in the terminal.
pip install bs4
  • requests:  Requests allows you to send HTTP/1.1 requests extremely easily. This module also does not comes built-in with Python. To install this type the below command in the terminal.
pip install requests

Approach:

  • Extract data form given URL
  • Scrape the data with the help of requests and Beautiful Soup
  • Convert that data into html code.
  • Find the required details and filter them.

Let’s see the stepwise execution of the script

Step 1:   Import all dependence 

Python3




import requests
from bs4 import BeautifulSoup


Step 2: Create a URL get function

Python3




def getdata(url):
    r = requests.get(url)
    return r.text


Step 3: Now pass the URL into the getdata function and Convert that data into HTML code

Python3




soup = BeautifulSoup(htmldata, 'html.parser')
res = soup.find_all("div", class_="is_h5-2 is_developer w-richtext")
print(str(res))


Output:

Note: These scripts will give you only Raw data in String format you have to print your data with your needs. 

Complete code:

Python3




import requests
from bs4 import BeautifulSoup
  
  
def getdata(url):
    r = requests.get(url)
    return r.text
  
soup = BeautifulSoup(htmldata, 'html.parser')
result = str(soup.find_all("div", class_="is_h5-2 is_developer w-richtext"))
  
print("NO 1 " + result[46:86])
print("NO 2 "+result[139:226])
print("NO 3 "+result[279:305])
print("NO 4 "+result[358:375])
print("NO 5 "+result[428:509])


Output:


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 29 Dec, 2020
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials