import requests
url = "https://example.com"
response = requests.get(url)
print("Response Code:", response.status_code)
print("Headers:", response.headers)
print("Content Preview:", response.text[:200])
Fetch and Print Website Content in Python
This Python script sends an HTTP GET request to a specified URL, retrieves the response, and prints key details such as the HTTP status code, response headers, and a preview of the page content. This is useful for checking website availability, API responses, web scraping, and debugging network requests.