Last active
November 19, 2018 12:10
-
-
Save dieegorenan/a3847f5bb8aea24bd8939f027fe1d452 to your computer and use it in GitHub Desktop.
Ireland IBAN random generator
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
""" | |
Please consider to visit https://bank.codes/ | |
""" | |
import requests | |
import re | |
import string | |
import random | |
URL_IBAN_GENERATOR = "https://bank.codes/iban/generate/ireland/" | |
def random_generator(size, chars): | |
return ''.join(random.choice(chars) for _ in range(size)) | |
def bank_code(): | |
return random_generator(size=4, chars=string.ascii_uppercase) | |
def branch_code(): | |
return random_generator(size=6, chars=string.digits) | |
def account_number(): | |
return random_generator(size=8, chars=string.digits) | |
r = requests.post(URL_IBAN_GENERATOR, data={ "input_0": bank_code(), "input_1": branch_code(), "input_2": account_number() }) | |
print(r.status_code, r.reason) | |
match = re.search("IE[0-9]{2}[A-Z]{4}[0-9]{14}", r.text) | |
if match: | |
print(match.group()) | |
else: | |
print("iban not found") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment