diff --git a/modules/amazon/pages.py b/modules/amazon/pages.py index 5cdc08817065ee994c6d0471f7a7d90772cf7099..6f97f76d78bfdc62bad3c9e1567b05226c3c8305 100644 --- a/modules/amazon/pages.py +++ b/modules/amazon/pages.py @@ -296,20 +296,21 @@ def obj_url(self): )(self) if not url: download_elements = async_page.doc.xpath('//a[contains(@href, "download")]') + order_summary_link = Link( + '//a[contains(text(), "Récapitulatif de commande")]|//a[contains(text(), "Order Summary")]', + default=NotAvailable + ) if download_elements and len(download_elements) > 1: # Sometimes there are multiple invoices for one order and to avoid missing the other invoices # we are taking the order summary instead - url = Link( - '//a[contains(text(), "Récapitulatif de commande")]', - default=NotAvailable - )(async_page.doc) + url = order_summary_link(async_page.doc) else: url = Coalesce( Link( '//a[contains(@href, "download")]|//a[contains(@href, "generated_invoices")]', default=NotAvailable, ), - Link('//a[contains(text(), "Récapitulatif de commande")]', default=NotAvailable), + order_summary_link, default=NotAvailable )(async_page.doc) doc_id = Field('id')(self)