-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcoding.py
More file actions
28 lines (19 loc) · 930 Bytes
/
coding.py
File metadata and controls
28 lines (19 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests
url = "https://gorest.co.in/public-api/users"
payload = {}
headers = {
'Cookie': '_gorest_session=r%2BBvzjOXrd%2Bnzm7PZAmgk8uHL0zBgVzTiSHjHeAMW7lCeQbnougpAJj7DFW4tRru%2BZxMF%2BgfnpmDA2aAAfms%2Fc5rDrD4h77iUNT1FKHIm3GyyttPrb41IzA9sckwd2KGbGH2%2BcD%2FCl1BIcCkAhRrL6yFxBIkl7T%2BPxsv0KEwTcz31m46uMY1OEuUC5rYvR2laiYDkIcqtlkCySMruCcj9ZjMvE%2BICL7N5Bpagl1XhKwTDDW0GfLcVmKKcBNNbJmtw%2FP1OqwKjcXtodeHWQQZuPZTgBR%2BmIA%3D--e%2BQr73izlCmBWSy2--yOmZzROPWDzaOBb6fUT24A%3D%3D'
}
response = requests.request("GET", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
# response = requests.get('https://gorest.co.in/public-api/users')
# print(response.text)
# convert json to Python object
x = response.json()
# print(type(x)) # dict
# print(x['data'][0]['name'])
# print(x['data'][1]['name'])
values = x['data']
# print(type(values)) # List
for n in range(len(values)):
print(values[n]['name'])