I've got a Python script that sends requests, it sends headers and data. I'm able to send, and its working. I've got a ONE of the headers that are being sent, a variable. That variable is being appended with a new character. My problem is, it only appends everytime I start the script, I need it to append everytime it sends and not have to restart the script everytime to send a newly generated item. I've pasted my code below
`
import requests
import string
import random
from time import sleep
RequestsSent = 0
i = 1
if(i > 0):
input_string = "guest=guest_acc8a45cdf57f7a"
alphabet = string.ascii_lowercase
random_character = random.choice(alphabet)
result_string = input_string + random_character
data = "xxxxxxxxxxxxx"
headers = {'xxxxx': 'xxxxx', 'xxxxx': result_string}
while(True):
r=requests.post(url, data=data, headers=headers)
#print(r.text)
RequestsSent += 1
i += 1
print("Requests sent: " + str(RequestsSent))
print("Sent guess ID: " + str(result_string))
sleep(5)
`
Output:
Requests sent: 1 Sent guess ID: guest=guest_acc8a45cdf57f7f
Requests sent: 2 Sent guess ID: guest=guest_acc8a45cdf57f7f
Requests sent: 3 Sent guess ID: guest=guest_acc8a45cdf57f7f
If I restart the script, then will it generate a new guess ID
I've tried putting the append as a infinite While loop but then that just sits on that forever and doesn't send data, the if statement doesn't work either,
Aucun commentaire:
Enregistrer un commentaire