Question
I needed to make a Python program that downloads a web page (by download I mean acquire the html, css, js, etc.) and display that
I needed to make a Python program that downloads a web page (by download I mean acquire the html, css, js, etc.) and display that information along with the headers associated with the site. I have some code here that does do what I mentioned for most sites such as youtube.com, yahoo.com, ubereats.com, etc., but my issue is when I try to run my program on google.com I get this error:
Traceback (most recent call last): File "C:/Users/Admin/PycharmProjects/networking/webDownload.py", line 19, in
Is there any way I can fix this? Here is my current code:
#importing module to access web pages import urllib.request; #getting a web page url from user webPage = input('Enter a web page url: '); #adding http at the beginning if not exists if not webPage.startswith('http'): webPage='http://' + webPage; #finding the response response = urllib.request.urlopen(webPage); #reading the contents of arbitrary web page content = response.read(); #displaying the web page which is the first part of the program print('============================== CONTENT OF WEB PAGE ============================== ',content.decode()); #displaying the header info which is the second part of the program print(' ============================== HEADER INFO ============================== ',response.info());
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started