Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
Email Id Extractor Project from sites in Scrapy Python
Next article icon

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

pip install bs4
pip install requests

Approach:

Let's see the stepwise execution of the script

Step 1:   Import all dependence 

Python3
importrequestsfrombs4importBeautifulSoup


Step 2: Create a URL get function

Python3
defgetdata(url):r=requests.get(url)returnr.text

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

Python3
htmldata=getdata("https://covid-19tracker.milkeninstitute.org/")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
importrequestsfrombs4importBeautifulSoupdefgetdata(url):r=requests.get(url)returnr.texthtmldata=getdata("https://covid-19tracker.milkeninstitute.org/")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:


Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp