Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few Amazon downloader fixes #38

Merged
merged 1 commit into from
Mar 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions finance_dl/amazon.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ def invoice_finder():

order_ids = set()
for invoice_link in invoices:
if invoice_link.text != "Invoice":
continue
href = invoice_link.get_attribute('href')
m = re.match('.*[&?]orderID=((?:D)?[0-9\\-]+)(?:&.*)?$', href)
if m is None:
Expand All @@ -187,9 +189,7 @@ def invoice_finder():
logger.info('Skipping already-downloaded invoice: %r',
order_id)
continue
print_url = 'https://www.amazon.%s/gp/css/summary/print.html?ie=UTF8&orderID=%s' % (
self.amazon_domain, order_id)
invoice_hrefs.append((print_url, order_id))
invoice_hrefs.append((href, order_id))
order_ids_seen.add(order_id)

# Find next link
Expand All @@ -214,17 +214,19 @@ def retrieve_all_order_groups():
num_options = len(order_select.options)
if order_select_index >= num_options:
break
option_text = order_select.options[
order_select_index].text.strip()
option = order_select.options[
order_select_index]
option_text = option.text.strip()
order_select_index += 1
if option_text == 'Archived Orders':
continue
if self.order_groups is not None and option_text not in self.order_groups:
logger.info('Skipping order group: %r', option_text)
continue
logger.info('Retrieving order group: %r', option_text)
with self.wait_for_page_load():
order_select.select_by_index(order_select_index)
if not option.is_selected():
with self.wait_for_page_load():
order_select.select_by_index(order_select_index - 1)
get_invoice_urls()

if regular:
Expand Down