peter-tanner / AliExpress-Invoice-Downloader

Adds download buttons to the Aliexpress order page (https://www.aliexpress.com/p/order/index.html) and a bulk download button to download all invoices on the order page to save time.
GNU General Public License v3.0
1 stars 0 forks source link

does not work as of 2024-05-02 w/ firefox-esr on debian #1

Open wolfgangr opened 2 months ago

wolfgangr commented 2 months ago

Hi Peter, thanks for your great idea! (Just manually downloaded ~130 invoices manually....) however, when I try it, it produces HTML instead:

<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>My&nbsp;AliExpress : Manage&nbsp;Orders</title>
<meta name="keywords" content="Alibaba Manufacturer Directory - Suppliers, Manufacturers, Exporters &amp; Importers" />^M
<meta name="description" content="Alibaba Manufacturer Directory - Suppliers, Manufacturers, Exporters &amp; Importers" 

(I'll try to add full size samples)

in my Downlaod dir, a funny looking directory tree is created:

...:~/Downloads$ tree invoice_3*
invoice_3033634097049161_NunDunco_20mm
invoice_3033634097069161_7pcs
invoice_3033634097089161_5pcs_16
└── 18
    └── 20
invoice_3033986156409161_90pcs_M3
└── M4
    └── M5
invoice_3033986156449161_NunDunco_20mm
└── 45.pdf
invoice_3033986156469161_CMCP_50
└── 60pcs_Ti.pdf
invoice_3034456563539161_Titanium_
invoice_3034456563559161_1

4 directories, 2 files

liegts an mir? hat ali das Interface geändert?

firefox 102.8.0esr auf debian10, noscript etc

wolfgangr commented 2 months ago

lloks like I can't add attachments - neither pseudo pdf nor zip

wolfgangr commented 2 months ago

this is the link that is produced for invoice download (retrieved from browser history) When I paste this in the address window, the invoice pdf correctly gets downloaded and opened

https://trade.aliexpress.com/ajax/invoice/invoiceExportAjax.htm?invoiceId=81422554729&orderId=3034800943659161

When I remove the invoiceID part, I get an error message

https://trade.aliexpress.com/ajax/invoice/invoiceExportAjax.htm?orderId=3034800943659161

The same error message I get, when I try your URL

const url = `https://trade.aliexpress.com/ajax/invoice/invoiceExportAjax.htm?orderId=${orderId}&name=${sanitizedFileName}`;

So do we have to add this invoice ID? Where to steal from?

wolfgangr commented 2 months ago

This is the source code of aliexpress order download button (manually reformatted):

<div class="order-status order-block" 
          data-spm="order_detail_status" 
          data-spm-anchor-id="a2g0o.order_detail.0.order_detail_status.2268f19c02NJBB">
    <div class="order-status-box">
        <div class="order-status-content">
            <div class="order-block-title" data-pl="order_block_title">
                Awaiting delivery
            </div>
        <div class="order-status-info" 
            data-pl="order_block_info" 
            data-spm-anchor-id="a2g0o.order_detail.order_detail_status.i1.2268f19c02NJBB">
                 The system will automatically confirm receipt after <span>22 days</span>. 
                   If there are any problems, you can apply for a refund/return within 90 days after order was placed.
        </div>
    </div>
</div>
    <button data-pl="order_block_btn" type="button" class="comet-btn comet-btn-primary">
        <span>Confirm received</span>
    </button>
    <button data-pl="order_block_btn" type="button" class="comet-btn">
        <span data-spm-anchor-id="a2g0o.order_detail.order_detail_status.i0.2268f19c02NJBB">
            Download invoice
        </span>
    </button>
</div>
peter-tanner commented 3 weeks ago

sorry been busy with uni lately

  1. The bad directory structure is my bad, I didn't remove slashes from filenames when titles contain them. I'm fixing this in the next release
  2. in my experience i dont need the invoiceid to download files successfully, they seem to work with the invoiceid omitted for me. I was trying to find the invoiceid but it seems a lot more tedious: To get the invoiceid I would need to call this api
    https://acs.aliexpress.com/h5/mtop.aliexpress.trade.buyer.order.detail/1.0/?jsv=$JSV&appKey=$KEY&t=$TIME&sign=$SIGN&api=mtop.aliexpress.trade.buyer.order.detail&method=GET&v=1.0&timeout=15000&dataType=originaljsonp&type=originaljsonp&callback=mtopjsonp1&data={"tradeOrderId":$ID,"clientPlatform":"pc","shipToCountry":$COUNTRY,"timeZone":"GMT+$OFFSET"}

    I've looked at trying to make it work but havent been successful, but its a lot more diffcult and i dont have much time recently.

if anyone has a PR to correctly include the invoiceid in the download url i'll accept it