56 lines
1.3 KiB
Python
Executable file
56 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import csv
|
|
import static
|
|
import requests
|
|
import threading
|
|
import queue
|
|
import bs4
|
|
import sys
|
|
|
|
def getFile(filename = 'list.csv', fieldnames = static.fieldlist):
|
|
with open(filename, "r") as csf:
|
|
return list(csv.DictReader(csf, fieldnames))
|
|
|
|
def getBalance(card, ccn, q = None, eq = None):
|
|
try:
|
|
with requests.Session() as session:
|
|
session.headers = {"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0"}
|
|
|
|
session.get("https://b2bpr.vaservices.eu/plb/PayLifeBalanceInquiry/")
|
|
|
|
data = {"j_username": card, "j_password": ccn, "Submit": "Submit"}
|
|
html = session.post("https://b2bpr.vaservices.eu/plb/PayLifeBalanceInquiry/j_security_check", data=data).text
|
|
|
|
balance = bs4.BeautifulSoup(html, "html5lib").findAll("td")[14].text
|
|
output = float(balance.replace(",", "."))
|
|
|
|
if q:
|
|
q.put((card, output))
|
|
|
|
return output
|
|
|
|
except:
|
|
if eq:
|
|
eq.put(sys.exc_info())
|
|
raise
|
|
|
|
if __name__ == "__main__":
|
|
q = queue.Queue()
|
|
eq = queue.Queue()
|
|
threads = []
|
|
|
|
for card in getFile():
|
|
t = threading.Thread(target=getBalance, args=(card["number"], card["ccn"], q, eq), daemon=True)
|
|
t.start()
|
|
threads += [t]
|
|
|
|
for t in threads:
|
|
t.join(10)
|
|
|
|
if not eq.empty():
|
|
exc = eq.get()
|
|
raise exc[1].with_traceback(exc[2])
|
|
|
|
while not q.empty():
|
|
print("%s: %.2f" % q.get())
|