Skip to content

Instantly share code, notes, and snippets.

@davehunt
Created November 8, 2018 09:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davehunt/e53a6c0d1a820782dd1344d84c007cf9 to your computer and use it in GitHub Desktop.
Save davehunt/e53a6c0d1a820782dd1344d84c007cf9 to your computer and use it in GitHub Desktop.
Show location and user agents from WebPageTest results
import json
with open("/Users/dhunt/Desktop/wpt.json") as f:
data = json.load(f)
for test in data:
location = test["data"]["location"]
request_headers = test["data"]["runs"]["1"]["firstView"]["requests"][0]["headers"]["request"]
user_agent = next(filter(lambda x: x.startswith("User-Agent:"), request_headers))
print(f"location: {location}")
print(f"- user-agent: {user_agent}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment