Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Lab 2 - Web Scraping Backend Layer (refers to data access and manipulation) : Using BeautifulSoup, scrape this website: "https://en.wikipedia.org/wiki/List_of_countries_by_carbon_dioxide_emissions"...

1 answer below »
Lab 2 - Web Scraping

Backend Layer (refers to data access and manipulation) :

Using BeautifulSoup, scrape this website:

"https://en.wikipedia.org/wiki/List_of_countries_by_carbon_dioxide_emissions"

Scrape the "List of countries by carbon dioxide emissions" for the data. Store the scraped data in an object from your SQLite database class from lab1.

Frontend Layer (refers to the user interface):

Using the database passed from the backend, sort the data by the Fossil CO2 Emissions 2017 (% of the world) column. Extract the top 10 countries' data, and plot them in a pie-graph using your Graphics module from lab1.


I attach lab 1 as well
Answered 7 days After Oct 19, 2021

Solution

Vicky answered on Oct 26 2021
134 Votes
# import li
aries
from bs4 import BeautifulSoup
import pandas as pd
import requests
# Extract html page content from url
url = "https:
en.wikipedia.org/wiki/List_of_countries_by_ca
on_dioxide_emissions"
content = requests.get(url)
soup = BeautifulSoup(content.text, "html.parser")
# Create list of all the columns of table
Countries=[]
one990 = []
two005 = []
two017 = []
two017world= []
two017vs1990 = []
perlandarea = []
percapita = []
totalincluding= []
totalexcluding = []
# Find all the elements of table
job = soup.find('table',attrs={'class':'wikitable sortable','style':'text-align:right'})
job_elems = job.find_all("td")
# Add table data to lists
for i in range(len(job_elems)):
if(i%10==0):
Countries.append(job_elems[i].text[1:])
elif(i%10==1):
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here