def parse_file(self, account, f): transactions = [] f.next() reader = csv.DictReader(f) for row in reader: date = datetime.datetime.strptime(row['Date'][0:10], '%m/%d/%Y').date() action = row['Action'] symbol = row['Symbol'] description = row['Description'] #quantity = row['Quantity'] #price = row['Price'] #fees = row['Fees & Comm'] amount = row['Amount'] if amount: amount = float(amount.replace('$', '')) full_description = action if symbol: full_description = '{} - {}'.format(action, description) transactions.append({ 'posted': date, 'description': full_description, 'amount': amount }) return Statement(account, transactions, self._statement.balance)
def download(self, account): parser = etree.HTMLParser(encoding='utf-8') doc = etree.fromstring(self.driver.page_source, parser) balance = doc.xpath( '//*[contains(text(), "Total Balance")]/following-sibling::p/text()' ) balance = float(balance[0].strip().replace('$', '').replace(',', '')) self._statement = Statement(account, [], balance) self.driver.get( 'https://ddol.divinvest.com/ddol/authenticated/reports/transactionHistory.html' ) time.sleep(2) select = Select(self.driver.find_element_by_id('startDate_Month_ID')) select.select_by_index(0) self.driver.find_element_by_xpath( "//a[contains(@href, 'submitted')]").click() time.sleep(2) self.driver.find_element_by_partial_link_text('download').click() script = """$('[name="downloadFormat"]').find('option[value="csv"]').attr('selected', true)""" self.driver.execute_script(script) return wait_for_file( self.dl_path, lambda: self.driver.find_element_by_name('downloadFormat').submit( ))
def download(self, account): self.driver.get( "https://client.schwab.com/secure/cc/accounts/balances") self.driver.find_element_by_id("accountSelector").click() wait_for(self.driver, By.PARTIAL_LINK_TEXT, account.site_key) self.driver.find_element_by_partial_link_text(account.site_key).click() parser = etree.HTMLParser(encoding='utf-8') doc = etree.fromstring(self.driver.page_source, parser) balance = doc.xpath( '//*[text()="Total"]/../following-sibling::td/*/text()') balance = balance[0].replace('$', '').replace(',', '') self._statement = Statement(account, [], balance) time.sleep(2) self.driver.get("https://client.schwab.com/secure/cc/accounts/history") self.driver.find_element_by_id("accountSelector").click() wait_for(self.driver, By.PARTIAL_LINK_TEXT, account.site_key) self.driver.find_element_by_partial_link_text(account.site_key).click() wait_for(self.driver, By.LINK_TEXT, "Edit Filter") self.driver.find_element_by_partial_link_text("Export").click() time.sleep(2) self.driver.switch_to.window(self.driver.window_handles[1]) wait_for(self.driver, By.LINK_TEXT, "OK") return wait_for_file( self.dl_path, lambda: self.driver.find_element_by_partial_link_text("OK").click( ))
def parse_file(self, account, f): f.next() f.next() f.next() f.next() transactions = [] reader = csv.DictReader(f) for row in reader: if row['Entry Date']: date = datetime.datetime.strptime(row['Entry Date'], '%d-%b-%Y') #transaction_type = row['Transaction Type'] description = row['Transaction Description'] symbol = row['Security ID'] #symbol_description = row['Security Description'] #quantity = row['Quantity'] #price = row['Price'] #fees = row['Fees & Comm'] amount = row['Net Amount'] if amount: amount = float(amount.replace('$', '')) full_description = description if symbol and symbol != '--': full_description = '{} - {}'.format(description, symbol) transactions.append({'posted':date, 'description':full_description, 'amount':amount}) return Statement(account, transactions, self._statement.balance)
def download(self, account): self.driver.switch_to.window(self.driver.window_handles[0]) self.driver.switch_to.frame(0) self.driver.switch_to.frame(0) self.driver.switch_to.frame(1) self.driver.switch_to.frame(0) self.driver.switch_to.frame(0) parser = etree.HTMLParser(encoding='utf-8') doc = etree.fromstring(self.driver.page_source, parser) balance = doc.xpath('//*[contains(text(), "Portfolio Total")]/text()') balance = float(balance[0].strip().replace('Portfolio Total: $', '').replace(',','')) self._statement = Statement(account, [], balance) self.driver.find_element_by_partial_link_text(account.site_key).click() self.driver.switch_to.frame(0) self.driver.find_element_by_id("pageTitledwnArr").click() self.driver.switch_to.window(self.driver.window_handles[0]) self.driver.switch_to.frame(0) self.driver.switch_to.frame(0) self.driver.switch_to.frame(9) self.driver.find_element_by_partial_link_text("Your Default").click() self.driver.switch_to.window(self.driver.window_handles[0]) self.driver.switch_to.frame(0) self.driver.switch_to.frame(0) self.driver.switch_to.frame(1) self.driver.switch_to.frame(0) self.driver.switch_to.frame(0) self.driver.switch_to.frame(1) wait_for(self.driver, By.PARTIAL_LINK_TEXT, 'Important History Information') return wait_for_file(self.dl_path, lambda:self.driver.find_element_by_id("export").click())
def download(self, account): wait_for(self.driver, By.PARTIAL_LINK_TEXT, account.site_key) self.driver.find_element_by_partial_link_text(account.site_key).click() parser = etree.HTMLParser(encoding='utf-8') doc = etree.fromstring(self.driver.page_source, parser) balance = doc.xpath( "//th[text()='Principal balance']/../td/text()")[0].replace( '$', '').replace(',', '') self.driver.find_element_by_partial_link_text( 'See transaction history').click() doc = etree.fromstring(self.driver.page_source, parser) transaction_content = doc.xpath("//div[@id='GridContainer1']//tr")[1:] transactions = [] for tr in transaction_content: date = datetime.datetime.strptime(tr[0].text, '%m/%d/%Y') description = tr[1].text amount = tr[2].text.replace('$', '').replace(',', '') transactions.append({ 'posted': date, 'description': description, 'amount': amount }) return Statement(account, transactions, balance)
def download(self, account): parser = etree.HTMLParser(encoding='utf-8') doc = etree.fromstring(self.driver.page_source, parser) net_cf = doc.xpath( "//div[contains(text(), 'Net Cash Value')]/../../../following-sibling::td/span/text()" ) net_cf = net_cf[0].replace('$', '').replace(',', '') self.driver.find_element_by_partial_link_text( 'Transaction History').click() select = Select(self.driver.find_element_by_id('display')) select.select_by_value("9") time.sleep(2) doc = etree.fromstring(self.driver.page_source, parser) transaction_content = doc.xpath( "//span[@class='cData' or @class='cdata']/text()") transactions = [] i = 0 while i < len(transaction_content): description = transaction_content[i] amount = transaction_content[i + 1].replace("$", "").replace(",", "") date = datetime.datetime.strptime(transaction_content[i + 2], '%m/%d/%Y') transactions.append({ 'posted': date, 'description': description, 'amount': amount }) i = i + 4 return Statement(account, transactions, net_cf)
def download(self, account): parser = etree.HTMLParser(encoding='utf-8') doc = etree.fromstring(self.driver.page_source, parser) amounts = doc.xpath("//tr/td[3][contains(text(), '$')]/text()") total = 0.0 for amount in amounts: f_amount = float(unicode(amount).encode('ascii', 'ignore').replace("$", '').replace(',','')) total += f_amount return Statement(account, [], total)
def download(self, account): wait_for(self.driver, By.LINK_TEXT, "Change Email") parser = etree.HTMLParser(encoding='utf-8') doc = etree.fromstring(self.driver.page_source, parser) amounts = doc.xpath("//div[contains(@class, 'currency')]/text()") total = 0.0 for amount in amounts: f_amount = float( unicode(amount).encode('ascii', 'ignore').replace("$", '').replace(',', '')) total += f_amount return Statement(account, [], total)
def parse_file(self, account, f): transactions = [] reader = csv.DictReader(f) for row in reader: transaction_type = row['Transaction Type'] date = datetime.datetime.strptime(row['Date'], '%m/%d/%y').date() source = row['Source'].strip() fund = row['Fund Name'] #unit_count = row['Unit Count'] #unit_value = row['Unit Value'] amount = row['Transaction Amount'] if amount: amount = float(amount) full_description = '{} - {} of {}'.format( transaction_type, source, fund) transactions.append({ 'posted': date, 'description': full_description, 'amount': amount }) return Statement(account, transactions, self._statement.balance)