dne-security-code
dne-security-code copied to clipboard
umbrella pagination with get request not working - EnforcementGetRequest.py
"url_get" variable is not updated correctly in the while loop, causing the next page not to load.
https://github.com/CiscoDevNet/dne-security-code/blob/master/intro-umbrella/EnforcementGetRequest.py
Original code
# keep doing GET requests, until looped through all domains
while True:
req = requests.get(url_get)
json_file = req.json()
for row in json_file["data"]:
domain_list.append(row["name"])
# GET requests will only list 200 domains, if more than that, it will request next bulk of 200 domains
if bool(json_file["meta"]["next"]):
Url = json_file["meta"]["next"]
# break out of loop when finished
else:
break
Fixed code
# keep doing GET requests, until looped through all domains
while True:
req = requests.get(url_get)
json_file = req.json()
for row in json_file["data"]:
domain_list.append(row["name"])
# GET requests will only list 200 domains, if more than that, it will request next bulk of 200 domains
if bool(json_file["meta"]["next"]):
url_get = json_file["meta"]["next"]
# break out of loop when finished
else:
break