Scraping Numbers from HTML using BeautifulSoup In this assignment you will write a Python program similar to http://www.py4e.com/code3/urllink2.py.

Scraping Numbers from HTML using BeautifulSoup In this assignment you will write a Python program similar to http://www.py4e.com/code3/urllink2.py. The program will use urllib to read the HTML from the data files below, and parse the data, extracting numbers and compute the sum of the numbers in the file.

We provide two files for this assignment. One is a sample file where we give you the sum for your testing and the other is the actual data you need to process for the assignment.

Don't use plagiarized sources. Get Your Custom Essay on
Scraping Numbers from HTML using BeautifulSoup In this assignment you will write a Python program similar to http://www.py4e.com/code3/urllink2.py.
Just from $13/Page
Order Essay
  • Sample data: http://py4e-data.dr-chuck.net/comments_42.html (Sum=2553)
  • Actual data: http://py4e-data.dr-chuck.net/comments_689313.html (Sum ends with 25)

You do not need to save these files to your folder since your program will read the data directly from the URL. Note: Each student will have a distinct data url for the assignment – so only use your own data url for analysis.

Data Format

The file is a table of names and comment counts. You can ignore most of the data in the file except for lines like the following:Modu90Kenzie88Hubert87

You are to find all the tags in the file and pull out the numbers from the tag and sum the numbers.

Look at the sample code provided. It shows how to find all of a certain kind of tag, loop through the tags and extract the various aspects of the tags….# Retrieve all of the anchor tagstags = soup(‘a’)for tag in tags: # Look at the parts of a tag print ‘TAG:’,tag print ‘URL:’,tag.get(‘href’, None) print ‘Contents:’,tag.contents[0] print ‘Attrs:’,tag.attrs

You need to adjust this code to look for span tags and pull out the text content of the span tag, convert them to integers and add them up to complete the assignment.

Sample Execution$ python3 solution.pyEnter – http://py4e-data.dr-chuck.net/comments_42.htmlCount 50Sum 2…

Turning in the Assignment

Enter the sum from the actual data and your Python code below: Sum: (ends with 25) Python code:

Order your essay today and save 20% with the discount code: GREEN

Order a unique copy of this paper

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
Top Academic Writers Ready to Help
with Your Research Proposal
Live Chat+1(978) 822-0999EmailWhatsApp