Last active
September 12, 2019 13:48
-
-
Save phorward/3c94b4bbecd5d486801c9084b1618454 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
# -*- coding: utf-8 -*- | |
import requests, argparse, sys, csv | |
from collections import OrderedDict | |
if __name__ == "__main__": | |
host = "https://www.xxx.de/" | |
sess = requests.Session() | |
ret = sess.post( | |
host + "/vi/user/auth_userpassword/login", | |
data={ | |
"name": "xxx@xxx.de", | |
"password": "xxx", | |
"skey": sess.get(host + "/vi/skey").json() | |
} | |
) | |
if not ret.ok: | |
print("Unable to logon") | |
sys.exit(1) | |
count = 0 | |
cursor = None | |
writer = None | |
f = open("out.csv", "w") | |
while True: | |
ret = sess.get(host + "/vi/module/list", params={"cursor": cursor, "amount": 99}).json() | |
if not ret["skellist"]: | |
break | |
cursor = ret["cursor"] | |
if writer is None: | |
writer = csv.DictWriter(f, [x[0] for x in ret["structure"]]) | |
writer.writeheader() | |
for skel in ret["skellist"]: | |
writer.writerow({k: v.encode("utf-8") if isinstance(v, basestring) else v for k, v in skel.items()}) | |
count += len(ret["skellist"]) | |
print("%d entries read so far" % count) | |
f.close() | |
print("All Done!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment