def main(): """ TO run this file sourcing root as src sudo PYTHONPATH=. ~/.pyenv/versions/3.7.0/envs/myproject/bin/python3.7 remittance/main.py :return: """ try: logger.error("=== Starting application ===") tab = Browser.open_new_tab(incognito=True, headless=True) polling_period = int(os.environ.get('POLLING_PERIOD', 5)) while True: loop(tab) time.sleep(60 * polling_period) except Exception as e: print(e) logger.error("Main loop crashed: {}".format(e))
import json import re from common import Browser, getConfig, getUserPass, getSecurityQuestions username, password = getUserPass('citibank.com') br = Browser.make() u1 = 'https://online.citibank.com/US/JPS/portal/Home.do' r1 = br.open(u1) print br.geturl() print [x.attrs for x in br.forms()] br.select_form(nr=2) br['username'] = username br['password'] = password br.submit() r2 = br.open('https://online.citibank.com/US/REST/accountsPanel/getCustomerAccounts.jws?ttc=742', data={}) d = json.loads(r2.read()) kill_tags = re.compile(r'<.*?>') kill_double_space = re.compile(r'\s+') def format_label(label): label = kill_tags.sub('',label) label = label.replace(':','')
def main(): site = 'barclaycardus.com' username, password = getUserPass(site) qa = getSecurityQuestions(site) br = Browser.make() u1 = 'https://www.barclaycardus.com/' r1 = br.open(u1) print '1' # form infos # print [x.attrs for x in br.forms()] # # controls # print [x.attrs for x in f.controls for f in br.forms()] print br.geturl() br.select_form(nr=0) br['userId'] = username r2 = br.submit() print '2' r2_text = r2.read() # hmmm fix up some shitty JS causing parse error r2_text = r2_text.replace('<!")','') r2.set_data(r2_text) br.set_response(r2) br.select_form(nr=0) br.set_all_readonly(False) if 'Enter Your Password' not in r2_text: #register PC #set remember device, meh? br.form.set_value(['true'], name='registerDevice') soup = BeautifulSoup(r2_text) questions = [x.text for x in soup.findAll('span', {'class': 'formLabel'}) if 'username' not in x.text.lower() and 'register' not in x.text.lower()] answers = ['answer1', 'answer2'] for question, answer in zip(questions,answers): if question in qa: print 'using config answer for security question' br[answer] = qa[question] print '%s : %s' % (question , qa[question]) else: print 'MISSING config answer for security question' br[answer] = raw_input('%s: ' % question) r3 = br.submit() print '3' r3_text = r3.read() # import IPython; IPython.embed() # hmmm fix up some shitty JS causing parse error r3_text = r3_text.replace('<!")','') r3.set_data(r3_text) br.set_response(r3) print '4' br.select_form(nr=0) br['password'] = password r4 = br.submit() r4_text = r4.read() soup = BeautifulSoup(r4_text) money = [x.text for x in soup.find(id='row1a').findAll('h1', {'class': None})] accountData = { 'current_balance': money[0], 'statement_balance': money[1], 'available_credit': money[2], 'revolving_credit_line': money[3], } accountName = [x.text for x in soup.findAll('h1', {'class': 'cardName'})][0] accountId = re.findall(r'Card ending in (\d{4})', r4_text, re.IGNORECASE)[0] print accountName print accountId print accountData
""" Run this on interpreter to run this test The test file run roots from src sudo PYTHONPATH=. ~/.pyenv/versions/3.7.0/envs/myproject/bin/python3.7 remittance/modules/test_files/test_rates.py """ from common import Browser from remittance.modules import RemitlyRate, RiaRate, XoomRate, WesternUnionRate tab = Browser.open_new_tab(incognito=True, headless=True) rate = RemitlyRate(tab).get_rate() print("Remitly rate: {}".format(rate)) rate = RiaRate(tab).get_rate() print("Ria rate: {}".format(rate)) rate = XoomRate(tab).get_rate() print("Xoom rate: {}".format(rate)) rate = WesternUnionRate(tab).get_rate() print("WU rate: {}".format(rate))