Created
January 28, 2014 18:05
-
-
Save miketaylr/8672922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!usr/bin/env/python | |
import argparse | |
import requests | |
UAS = { | |
"b2g": "Mozilla/5.0 (Mobile; rv:18.1) Gecko/18.1 Firefox/18.1", | |
"fxa": "Mozilla/5.0 (Android; Mobile; rv:26.0) Gecko/26.0 Firefox/26.0" | |
} | |
def make_request(url, ua): | |
session = requests.Session() | |
session.headers.update({'User-Agent': ua}) | |
r = session.get(url, allow_redirects=False) | |
return r | |
def dump(response): | |
print("Response for: '{}'".format(response.request.headers['user-agent'])) | |
print("Response Status: {}".format(response.status_code)) | |
for key, value in response.headers.iteritems(): | |
print("{}: {}".format(key, value)) | |
print("\n") | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description=("Dump the response headers" | |
"for a given URL for FxOS and FxA")) | |
parser.add_argument("url") | |
args = parser.parse_args() | |
for ua in UAS.itervalues(): | |
response = make_request(args.url, ua) | |
dump(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment