1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

iMacro script for exporting all orders on Aliexpress to file (ali-export-all-orders.iim)

Discussion in 'Other Scripting Languages' started by DropBock, Feb 22, 2016.

Thread Status:
Not open for further replies.
  1. DropBock

    DropBock Newbie

    Joined:
    Dec 28, 2015
    Messages:
    12
    Likes Received:
    3
    Just finished with testing and fixing my script for today. Its called ali-export-all-orders.iim


    Selection_517.jpg

    its pretty self explanatory but just in case,

    first you have to save the code in a new file under the macro folder.
    then you fire up a new browser session , WARNING: iMacro will close open tabs.
    then you go to Selection_513.jpg (without ?)
    then you note the number of pages with orders(bottom at the page), in my case it would be 8: Selection_512.jpg
    then you insert that number in iMacro frame inside browser like this: Selection_514.jpg
    and finally you play loop and take a coffe break. its possible to use computer at the same time but for me it went best if i let the active window be the iMacro working window.

    The result is a bunch of .csv files and it look like this: Selection_515.jpg

    fileformat: orders_(name of the person its supposed to ship)_(status)_(order-id)

    the content of the .csv files is pretty messed up and not even comma delimited but it works great for me.

    example:
    Selection_516.jpg


    perhaps someone might find it useful.

    Regards from Martin
     
    • Thanks Thanks x 3
  2. JimmyPoopa

    JimmyPoopa Newbie

    Joined:
    May 2, 2014
    Messages:
    3
    Likes Received:
    2
    Just used this. Works great! Only thing you forgot to mention is that this needs to be played with iMacros for Firefox. I tried with Chrome first and struggled.
     
    • Thanks Thanks x 1
  3. DeerShoot

    DeerShoot Newbie

    Joined:
    Feb 16, 2017
    Messages:
    3
    Likes Received:
    1
    It dosent work.

    I save it as .iim and Play (Loop) 64 Times but get this error:
    Retry timeout, line: 58 (Error code: -1001)
     
    Last edited: Feb 16, 2017
  4. DropBock

    DropBock Newbie

    Joined:
    Dec 28, 2015
    Messages:
    12
    Likes Received:
    3
    you can probably make it work by removing line 28 which says "SET !ERRORIGNORE NO"
     
  5. DropBock

    DropBock Newbie

    Joined:
    Dec 28, 2015
    Messages:
    12
    Likes Received:
    3
    btw. is someone wants a cleaner code and/or customized i could perhaps help you. just give me a try in PM.
     
  6. DeerShoot

    DeerShoot Newbie

    Joined:
    Feb 16, 2017
    Messages:
    3
    Likes Received:
    1
    I have not much, but would be willing to donate 10 € if I have a way to export all the orders to a csv file.
     
    • Thanks Thanks x 1
  7. DeerShoot

    DeerShoot Newbie

    Joined:
    Feb 16, 2017
    Messages:
    3
    Likes Received:
    1
    It doesnt work if i comment out the line 28

    I habe over 60 pages and i think the script needs to much ram or there is an other problem with the script or imacro :/ I'm looking for a long time but i dint not find a working script. But the author of this scripts post it on over 15 sites....and now i come here to use it and it doesnt work :(

    I Hope really anyone can help
     
  8. DropBock

    DropBock Newbie

    Joined:
    Dec 28, 2015
    Messages:
    12
    Likes Received:
    3
    Here is a new script. it loops the order pages and opens each page of the orders and download each as html file and when its done im using a script that converts the html file to readable format.

    To use the iMacro script you have to be on the order page at aliexpress.com
    also you have to change 68 in the iMacro javascript file "for(l=1;l<68;l++)" to the count of your order pages. (plus one)

    i have tried it and it seems to work well, actually its run full for the first time right now but im tired and have been coding all night so beware of bugs.

    iMacro script:
    Code:
    var load;
    load =  "CODE:";
    //* load +=  "SET !ERRORIGNORE YES" + "\n";  *//
    load +=  "TAG POS={{i}} TYPE=A ATTR=TXT:View<SP>Detail" + "\n";
    load +=  "WAIT SECONDS=1" + "\n";
    
    load +=  "TAB T=2" + "\n";
    load +=  'TAG POS=1 TYPE=* ATTR=CLASS:"order-no" EXTRACT=TXT' + "\n";
    load +=  "SAVEAS TYPE=HTM FOLDER=* FILE=ali_order-ID-{{!EXTRACT}}" + "\n";
     load +=  "TAB CLOSE " + "\n"; 
     load +=  "TAB T=1" + "\n";
    
    
    var MACRO2;
    MACRO2 =  "CODE:";
    MACRO2 +=  'TAG POS=1 TYPE=A ATTR=TXT:{{l}}' + "\n";
    MACRO2 +=  "WAIT SECONDS=2" + "\n";
    
    
    
    for(l=1;l<68;l++) {
      iimSet("l",l);
    
    
    for(i=1;i<11;i++) {
      iimSet("i",i);
      iimPlay(load);
    
    
    }
    iimSet("l",l);
    iimPlay(MACRO2);
    }
    
    the script
    Code:
    #!/bin/bash
    
    for i in $(ls iMacros/Downloads/ali_order-ID-*); do
    order_id_from_file=$(echo $i |grep [0-9*]*.htm|grep [0-9*] -o |tr -d '\n')
    
    echo printing shit to the file $order_id_from_file
    
    if [ -f  $order_id_from_file.txt ]
    then
        echo "File $order_id_from_file.txt  exists, making backup and comparing"
    cp $order_id_from_file.txt $order_id_from_file.bak
    rm $order_id_from_file.diff
    do_compare=YES
    else
    do_compare=NO
    fi
    
    cat $i| grep baobei-name  -A1 $i|html2text |tr -cd "[:print:]\n"|sed  '/^$/d' |sort -u > $order_id_from_file.txt
    
    cat $i| grep '<dd class="order-no">' $i |html2text >> $order_id_from_file.txt
    
    cat $i |grep ' <div class="user-shipping"' -A120  |grep data-status\=\"[0-9,a-z,A-Z,_]* -o >>  $order_id_from_file.txt
    
    cat $i| grep '<dd class="order-status">'  -A5 $i|html2text  >> $order_id_from_file.txt
    
    
    if [ "$do_compare" ==  YES ]
    then
    echo comparing..
    diff $order_id_from_file.txt $order_id_from_file.bak > $order_id_from_file.diff
    fi
    
    
    done
    cat *.diff
    

    that would be great. you can sponsor me at paypal.me/somethingornothing


    atm its not CSV at all but more like this;
     
  9. DropBock

    DropBock Newbie

    Joined:
    Dec 28, 2015
    Messages:
    12
    Likes Received:
    3
    sorry about that, it was bad coded. i tried it for the first time in like a year today and it hanged my browser too.


    but i have not posted that script to 15 different sites. thats a lie!
     
  10. DropBock

    DropBock Newbie

    Joined:
    Dec 28, 2015
    Messages:
    12
    Likes Received:
    3
    sorry about the bash script. it did not work as expected but it should not be too hard to fix this.

    perhaps im able to do it tonight.
     
  11. DropBock

    DropBock Newbie

    Joined:
    Dec 28, 2015
    Messages:
    12
    Likes Received:
    3
    it was easier than suspected. i changed one line only "cat tjoho" to "cat $i" and it works.

    what follows is an lazy attempt to convert the outpupt to csv. (in linux bash but would also work in windows trough cygwin)

    for i in $(ls |xargs ls [5-9]*.txt); do echo $i $(head -2 $i|tail -1 |grep "Contact Name"[a-z,A-Z\ \:]* -o)|awk -F: '{print $2}'; done > data.1-names

    for i in $(ls |xargs ls [5-9]*.txt); do echo $i $(head -1 $i|tail -1); done |awk -F\ '{print $2}' > data.2-id

    for i in $(ls |xargs ls [5-9]*.txt); do echo $i $(head -8 $i|tail -6); done > data.3-address

    for i in $(ls |xargs ls [5-9]*.txt); do echo $i $(head -12 $i|tail -4); done > data.4-products

    for i in $(ls |xargs ls [5-9]*.txt); do grep data-status $i ; done > data.5-data-status

    for i in $(ls |xargs ls [5-9]*.txt); do grep order-status $i ; done > order.6-status

    paste -d, data.* > tjenamoss.csv


    (there are some serious bugs with this i think. for example the delimiter "," could also exist in product titles and then it fails very good and also im not satisfied with the file/column called 'data.4-products' )
     
Thread Status:
Not open for further replies.