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 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
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 : ... 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 :

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

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 ?
the script of imacros
(390 Bytes) Downloaded 97 times
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= ... 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 += "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";


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


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