Skip to content

Instantly share code, notes, and snippets.

@gabrieleromanato
Created April 18, 2022 10:06
Show Gist options
  • Save gabrieleromanato/28f719150d46a549572db83e9cbcb5d2 to your computer and use it in GitHub Desktop.
Save gabrieleromanato/28f719150d46a549572db83e9cbcb5d2 to your computer and use it in GitHub Desktop.
Cloudflare: get HTTP headers of a given domain/URL
import requests
import validators
from validators import ValidationFailure
class CloudflareRequest:
def __init__(self, url):
self.url = url
def send(self):
valid_url = validators.url(self.url.strip())
if isinstance(valid_url, ValidationFailure):
return False
r = requests.get(self.url, allow_redirects=True)
return r.headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment