Last active
February 28, 2018 08:56
-
-
Save binhqd/152401f5617fb3f01c6046c3d8e6478c to your computer and use it in GitHub Desktop.
Script for getting API response time in second
This file contains hidden or 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/python | |
import requests | |
import sys | |
import uuid | |
SCHEMA=sys.argv[1] | |
ORIGIN=sys.argv[2] | |
API_HOST=sys.argv[3] | |
URI=sys.argv[4] | |
API_URL = SCHEMA + '://' + API_HOST + URI | |
headers = { | |
"Host": API_HOST, | |
"Origin": SCHEMA + '://' +ORIGIN, | |
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36" | |
} | |
r = requests.request('GET', API_URL, headers=headers) | |
if r.status_code == 200: | |
print r.elapsed.total_seconds() | |
else: | |
print 40 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment