Is there a way to get the headers from url in any format like charles proxy does in python.
-
What do you mean exactly? A URL doesn't have headers, but HTTP requests and responses do. Are you receiving a request, or a response, or are you wanting to set headers on one of those?ndc85430– ndc854302022年11月08日 07:03:04 +00:00Commented Nov 8, 2022 at 7:03
1 Answer 1
Yes, there is a way to get headers from an URL in Python programming language. The requests module provides a way to do this.
import requests
url = "https://www.google.com"
response = requests.head(url)
print(response.headers) # prints the entire header as a dictionary
print(response.headers["Content-Length"]) # prints a specific section of the
dictionary
https://www.folkstalk.com/tech/python-get-response-headers-with-code-examples/
Sign up to request clarification or add additional context in comments.
Comments
lang-py