From f3f020cc657e77b914d9d8bbb16a0f903c6b8fa8 Mon Sep 17 00:00:00 2001 From: Ilyas Semmaoui Date: Thu, 27 May 2021 19:05:22 +0200 Subject: [PATCH] [amazon] handle order summary for english websites The order summary document was properly handled only for the french website. --- modules/amazon/pages.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/amazon/pages.py b/modules/amazon/pages.py index 5cdc088170..6f97f76d78 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) -- GitLab