Last active
April 24, 2020 06:00
-
-
Save DerekHawkins/b913ec0df500e8872ba89ea6ca309865 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
service_url = "https://www.googleapis.com/pagespeedonline/v5/runPagespeed/" | |
def speed_test_url(url, device): | |
params = { | |
"?url": url, | |
'strategy': device, | |
'key': key, | |
} | |
data = urllib.parse.urlencode(params, doseq=True) | |
main_call = urllib.parse.urljoin(service_url, data) | |
main_call = main_call.replace(r'%3F', r'?') | |
return main_call | |
test_url = speed_test_url(url='https://example.com', device='mobile') | |
response = requests.get(test_url).json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment