0

Is there a way to get the headers from url in any format like charles proxy does in python.

asked Nov 8, 2022 at 6:57
1
  • 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? Commented Nov 8, 2022 at 7:03

1 Answer 1

3

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/

answered Nov 8, 2022 at 7:03
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.