Question: In Python 3, using urllib.request and NO OTHER packages: Given: def readWebPage(): response = urllib.request.urlopen(http://www.cs.queensu.ca) html = str(response.read().decode('utf-8')) #I made a change to this on

In Python 3, using urllib.request and NO OTHER packages:

Given:

def readWebPage(): response = urllib.request.urlopen("http://www.cs.queensu.ca") html = str(response.read().decode('utf-8')) #I made a change to this on November 26th. #returns a string containing the web page source code return html

a) Get a list of links from the page. Your links should show both the link address (ie. the url) and the text that is displayed for the link. So, for the above example, you would display https://www.w3schools.com Visit W3Schools.com!

Get ALL the links and display them in the format shown above.

b) Get a list of image sources and display. For instance, if you see print "cat.jpg" on the screen. Make a list of these sources.

c) Count the number of paragraphs in the web page. A paragraph begins with a

tag.

d) Change the first occurrence of a paragraph tag (

) to a top level header. A top level header tag is

.

e) Add a paragraph of information at the start of the file (immediately following the

tag. Remember, a paragraph must contain a begin and end tag (

). You may "hard code" the information to add. Keep it clean -- offensive material will earn you a 0 on this assignment.

f) Write the current html to a new file with the name of the file being specified by the user. You should force the user to use the file extension ".html".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!