Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Programming: I need help with the following code assignmnent in Python. Thank you so much. Python Code #To get you started, Ive provided you

Python Programming: I need help with the following code assignmnent in Python. Thank you so much.

Python Code

#To get you started, Ive provided you the beginning part of the program.

#Analyze the program to understand why it works.

#!/usr/bin/python

import urllib2# this is a Python module that can be used for fetching URLs

import string # this is a Python module that can be used for fetching strings

lab71 = ""#lab71 is a string

# 1. Retrieve the index page from www.cisco.com.

for line in urllib2.urlopen("http://www.cisco.com"): #here we are opening the URL www.cisco.com

if 'href=' in string.lower(line): #in bash scripting we used grep

lab71 = lab71 + line #

f = open("lab7-1.txt","w") #

f.write(lab71) #

#2. need to delete character " " from index.html and save into a new file named index1. html

#3 need to look over the index1.html and see entries with

  • #4 You may need to store this information for later as well look at #code from step 1

    #5 need to remove the delimeter / save this step in a file called #lab7-2.txt

    #6 need to remove the delimeter \. and another delimeter \ and then a .com Save this step in a file called lab7.3.txt

    #7 remove duplicates from the list using :

    # Set(MlistVarName>) to convert a set back to a unique

    #list try: list(set(

    #8. Sort the list of address. See list functions.

    #9. Save the final list to a file called lab7-4.txt

    #10. convert the host name to an IP address

    #11. filter result to remove unwanted data as we only need lines with has address

    #12. output final name lab7-final.txt

  • Step by Step Solution

    There are 3 Steps involved in it

    Step: 1

    blur-text-image

    Get Instant Access to Expert-Tailored Solutions

    See step-by-step solutions with expert insights and AI powered tools for academic success

    Step: 2

    blur-text-image

    Step: 3

    blur-text-image

    Ace Your Homework with AI

    Get the answers you need in no time with our AI-driven, step-by-step assistance

    Get Started

    Recommended Textbook for

    More Books

    Students also viewed these Databases questions