forked from nikolas-n/Speedport-Plus-Cosmote-Router-hacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_data.py
38 lines (29 loc) · 1.05 KB
/
get_data.py
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
29
30
31
32
33
34
35
36
37
38
#!/bin/python3
import requests
import os
import urllib3
import json
# Suppress loggin about self-signed certificate
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Set headers
headers = {'Accept-Language': 'en'}
# Start session
session = requests.Session()
# Set username and password
login_data = {'showpw':'0','username':'**********','password':'********'}
# Login
session.post('https://192.168.1.1/data/Login.json',data=login_data,headers=headers,verify=False)
# Load endpoints
with open('endpoints_list.txt') as endpoints_list:
endpoints = endpoints_list.readlines()
# Create directory if it doesn't exist
if not os.path.exists('my_router_responses'):
os.makedirs('my_router_responses')
# Download JSONs
for endpoint in endpoints:
endpoint = endpoint.strip('\n')
print('Retrieving endpoint '+endpoint)
url='https://192.168.1.1/data/'+endpoint
request = session.get(url, headers=headers,verify=False)
pretty_json = json.dumps(json.loads(request.text),indent=4)
print(pretty_json, file=open('my_router_responses/' + endpoint, "a"))