Created
April 29, 2022 18:29
-
-
Save Pzdrs/ac1c5f32872a64e5ec1e59d783bd9ca9 to your computer and use it in GitHub Desktop.
Decode osobni cisla from finek email s vysledkama z testu
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
| import requests as requests | |
| headers = { | |
| "Accept": "application/json", | |
| "Authorization": 'Basic <base64 encoded "username:password">' | |
| } | |
| with open("data.txt", mode='r') as data: | |
| lines = data.readlines() | |
| with open("translated_data.txt", mode='a', encoding='utf-8-sig') as translation: | |
| for i, line in enumerate(lines): | |
| split_data = line.split(' ') | |
| response = requests.request('GET', | |
| f'https://stag-ws.tul.cz/ws/services/rest2/student/getStudentInfo?osCislo={split_data[0]}', | |
| headers=headers) | |
| if response.status_code != 200: | |
| print("chyba pro", split_data[0]) | |
| else: | |
| json_data = response.json() | |
| translation.write('{} {} {}'.format(json_data['jmeno'], json_data['prijmeni'], split_data[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment