Problem in Nested Looping

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
deskarnet
Posts: 2
Joined: Tue Mar 13, 2018 4:13 pm

Problem in Nested Looping

Post by deskarnet » Tue Mar 13, 2018 10:12 pm

I have been assigned to collect information from marketplace website. This responsibility is very important for me because it's relating to my promotion in my job. The link of the marketplace is :
https://shopee.co.id/Handphone-Aksesori ... rtBy=sales

it's consist of a number of pages, and each page contain 50 products. I must be able click each the link product, each the next navigation button to move to next page, and collect data on each of it by using imacros. The imacros script that I have created so far :

VERSION BUILD=8970419 RECORDER=FX
TAB T=1
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:shopee-item-card__text-name
TAG POS=1 TYPE=H1 ATTR=CLASS:shopee-product-info__header__text&&ITEMPROP:name EXTRACT=TXT
TAG POS=1 TYPE=DIV ATTR=CLASS:shopee-product-info__header__real-price EXTRACT=TXT
TAG POS=1 TYPE=DIV ATTR=CLASS:shopee-product-info__header__sold-count EXTRACT=TXT
TAG POS=1 TYPE=DIV ATTR=CLASS:shopee-product-detail__parameters__content EXTRACT=TXT
TAG POS=2 TYPE=DIV ATTR=CLASS:shopee-product-detail__parameters__content EXTRACT=TXT
TAG POS=3 TYPE=DIV ATTR=CLASS:shopee-product-detail__parameters__content EXTRACT=TXT
TAG POS=4 TYPE=DIV ATTR=CLASS:shopee-product-detail__parameters__content EXTRACT=TXT
TAG POS=5 TYPE=DIV ATTR=CLASS:shopee-product-detail__parameters__content EXTRACT=TXT
TAG POS=6 TYPE=DIV ATTR=CLASS:shopee-product-detail__parameters__content EXTRACT=TXT
TAG POS=1 TYPE=DIV ATTR=CLASS:product-page-seller-info__shop-name EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=F:\KRIS\ FILE=CONTOH.CSV
BACK


The problem is, so far this script is only working in each page, and it does not able to move to next page automatically. Could anyone give me some advice ?
Attachments
#SHopeeKRIS1.rar
the script of imacros
(390 Bytes) Downloaded 218 times
deskarnet
Posts: 2
Joined: Tue Mar 13, 2018 4:13 pm

Re: Problem in Nested Looping

Post by deskarnet » Thu Mar 15, 2018 3:20 am

The problem has been solved. I use javascript code.

//var macro0 = "FILTER TYPE=IMAGES STATUS=ON" + "\n";
//macro0 += "URL GOTO=https://shopee.co.id/Handphone-Aksesori ... rtBy=sales" + "\n";

//var macro1 = "SET !TIMEOUT_STEP 0" + "\n";
//macro1 += "TAG POS={{i}} TYPE=SECTION ATTR=CLASS:aditem-image CONTENT=MOUSEOVER" + "\n";
//macro1 += "TAG POS=R1 TYPE=A ATTR=* EXTRACT=TXT" + "\n";
//macro1 += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=javascript_test.csv" + "\n";

var macro1 = "SET !TIMEOUT_STEP 0" + "\n";
var macro1 = "FILTER TYPE=IMAGES STATUS=ON" + "\n";
macro1 += "TAG POS={{i}} TYPE=DIV ATTR=CLASS:shopee-item-card__text-name" + "\n";
macro1 += "WAIT SECONDS=2" + "\n";
macro1 += "TAG POS=1 TYPE=H1 ATTR=CLASS:shopee-product-info__header__text EXTRACT=TXT" + "\n";
macro1 += "TAG POS=1 TYPE=DIV ATTR=CLASS:shopee-product-detail__parameters__content EXTRACT=TXT" + "\n";
macro1 += "SAVEAS TYPE=EXTRACT FOLDER=F:\KRIS\ FILE=CONTOH3.CSV" + "\n";
macro1 += "BACK" + "\n";
//macro1 += "WAIT SECONDS=2" +"\n";

var macro2 = "WAIT SECONDS=2" +"\n";
macro2 += "TAG POS=1 TYPE=BUTTON ATTR=CLASS:shopee-icon-button<SP>shopee-icon-button--right<SP>" + "\n";
macro2 += "WAIT SECONDS=2" +"\n";
//macro2 += "TAG POS=1 TYPE=A ATTR=TXT:{{j}}" +"\n";

//iimPlayCode(macro0);

for (j = 1; j <= 5; j++) {
//iimSet("j", j);
if (j > 1) {
iimPlayCode(macro2);
}
//break;
for (i = 1; i <= 5; i++) {
iimSet("i", i);
var ret = iimPlayCode(macro1);
iimPlayCode(macro1);
//if (ret != 1)
//break;
}

}

I will appreciate for anyone who try to give idea to improve the code in order to be more simple and powerful.
Attachments
backup.rar
(736 Bytes) Downloaded 232 times
Post Reply