I have a simple python script that's repeating a HTTP response/request. I would like to know how I could have constructed this better, particularly if there's a way I could have incorporated the slice operator to cut down on my variable usage.
For context - the response contained a JSON string in between the <ExecuteResult>
flags that I'm removing currently with split()
import requests
import json
from pprint import pprint
url = "<redacted>"
cookies = {<redacted>}
headers = {<redacted>}
data="<redacted>"
submissions = input("How many submissions to create:")
while submissions > 0:
response = requests.post(url, headers=headers, cookies=cookies, data=data)
xml_string = response.content
json_file = xml_string.split('<ExecuteResult>')[1]
json_file = (json_file.split('</ExecuteResult>')[0]).replace("\\", "")
json_response = json.loads(json_file)
print "Created Id: " + json_response['_entity']['Id']
submissions -= 1
data
and/orurl
actually change for the different submissions? \$\endgroup\$