Problem in Nested Looping

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.
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 48 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 47 times
Post Reply