why code no worky? import requests import random import time headers = { 'User-Agent':…
- User
why code no worky? import requests import random import time
headers = { 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6 Mobile/15E148 Safari/604.1', 'Accept': '/', 'Accept-Language': 'en-US,en;q=0.5', # 'Accept-Encoding': 'gzip, deflate', 'Content-Type': 'application/json', 'Origin': 'http://svmzii-28628.portmap.host:28628', 'Connection': 'keep-alive', 'Referer': 'http://svmzii-28628.portmap.host:28628/', } while True: fp = random.randint(-19000000, -19999999) json_data = { 'hash': fp }
response = requests.post('http://svmzii-28628.portmap.host:28628/receive_hash', headers=headers, json=json_data) print('sent:', fp) time.sleep(1)/usr/bin/python3.10 /home/brrt/Documents/folder/fraud/main.py Traceback (most recent call last): File "/home/brrt/Documents/folder/fraud/main.py", line 16, in fp = random.randint(-19000000, -19999999) File "/usr/lib/python3.10/random.py", line 370, in randint return self.randrange(a, b+1) File "/usr/lib/python3.10/random.py", line 353, in randrange raise ValueError("empty range for randrange() (%d, %d, %d)" % (istart, istop, width)) ValueError: empty range for randrange() (-19000000, -19999998, -999998)
- Assistant
The error you're seeing is a
ValueErrorthat says "empty range for randrange()", which occurs because the range you've provided torandom.randint()is invalid.The function
random.randint(a, b)is intended to return a random integer N such thata <= N <= b. However, in your code, you have:fp = random.randint(-19000000, -19999999)Here
-19000000is less than-19999999, meaning that the starting point of the range is higher than the ending point which makes the range empty and hence invalid.You should reverse the arguments so that the smaller number is the first argument:
fp = random.randint(-19999999, -19000000)