Web Content Downloader

Write a Python program that takes a URL and downloads the content of the webpage. The program should handle exceptions for with time, like invalid URL, no internet connection, etc.

Example 1:

Input: "https://www.example.com"
Output: "<!doctype html>..."

Example 2:

Output: "Exception: Invalid URL"

Use Python’s requests module to download the webpage.

import requests

def download_webpage_content(url):
        response = requests.get(url)
        return response.text
    except requests.exceptions.RequestException as e:
        return "Exception: Invalid URL or no internet connection"


© Let’s Data Science


Unlock AI & Data Science treasures. Log in!