Created
October 6, 2019 19:39
-
-
Save qi-qi/a39079556fe1eb4e52742964464a880b 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
import requests | |
import json | |
from collections import OrderedDict | |
d1 = {} | |
d2 = {} | |
personal_number = "yyyymmdd-xxxx" | |
for i in range(1000000, 1000400): | |
payload = {"bookingSession": {"socialSecurityNumber": personal_number, "licenceId": 5, "bookingModeId": 0, | |
"ignoreDebt": "false", "examinationTypeId": 0, "rescheduleTypeId": "0"}, | |
"occasionBundleQuery": {"startDate": "2018-01-15T23:00:00.000Z", "locationId": i, "languageId": 4, | |
"vehicleTypeId": 4, "tachographTypeId": 1, "occasionChoiceId": 1, | |
"examinationTypeId": 0}} | |
r = requests.post("https://fp.trafikverket.se/Boka/occasion-bundles", json=payload) | |
if r.status_code == 200: | |
data = json.loads(r.text)['data'] | |
if data: | |
result = data[0] | |
test_paper = result['occasions'][0] | |
test_car = result['occasions'][1] | |
# d1[test_paper['locationName']] = test_paper['duration']['start'] | |
d2[test_car['locationName']] = test_car['duration']['start'] | |
d_sorted_by_value = OrderedDict(sorted(d2.items(), key=lambda x: x[1])) | |
for k, v in d_sorted_by_value.items(): | |
print(k, '\t', v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment