import requests
def batch_header_request(url, headers):
"""
Batches request headers for compatibility with older Python versions.
Args:
url (str): The URL to make the request to.
headers (dict): A dictionary of headers to include in the request.
Returns:
requests.Response: The response object from the request.
"""
try:
response = requests.get(url, headers=headers) # Use requests.get to make the request
return response
except Exception as e:
print(f"An error occurred: {e}")
return None
if __name__ == '__main__':
# Example Usage
url = "https://httpbin.org/headers" # Example URL
headers = {
"User-Agent": "MyCustomAgent/1.0",
"X-Custom-Header": "MyValue"
}
response = batch_header_request(url, headers)
if response:
print(response.json()) # Print the response as JSON
Add your comment