Extract uncertain DIV Class

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
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Extract uncertain DIV Class

Post by Cornysz » Mon Apr 13, 2020 12:14 pm

BUILD=8970419
Freeware
Win 10
Firefox 56

Hello, I'm still newbie about iMacros
So in the site, there are many DIV class, something showing around 50 - 60 (random). I'm use loop to start but i dont know how to click a button. And i want to after TAG all that DIV line, click a button. But how to do that?
Thank you in advance.
Attachments
foto shopee.png
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract uncertain DIV Class

Post by chivracq » Mon Apr 13, 2020 3:06 pm

Cornysz wrote:
Mon Apr 13, 2020 12:14 pm

Code: Select all

BUILD=8970419 Freeware
Win 10
Firefox 56
Hello, I'm still newbie about iMacros
So in the site, there are many DIV class, something showing around 50 - 60 (random). I'm use loop to start but i dont know how to click a button. And i want to after TAG all that DIV line, click a button. But how to do that?
Thank you in advance.

OK, this one approved, and of much better Quality than your 1st Post/Thread... :D

But hum, I don't understand your Qt/Pb, without any Script nor URL posted..., record your Actions for 2 or maybe 3 'DIV' Blocks and see how you can loop those Actions with just 1 Block..., and post those 2 Scripts if you encounter a Pb, not much we can do at the moment without seeing your Script(s)...

And maybe give also "the big Picture" of your Scenario and what you want to do, because I don't understand why you would want to extract the Class of a 'DIV', especially if there are 60 Elements with the same Class... :? Data Extraction is about "extracting some Data", while the Class of an Element is pertinent for the HTML Structure of a Page...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: Extract uncertain DIV Class

Post by Cornysz » Wed Apr 15, 2020 7:44 pm

Okay sorry for my bad english, it's make me hard to explain it :roll:
i hope you can understand this qt

So in this photo, sometimes the square/grid show in the page 50, or 55 or 60 (erratic) thats make me hard to TAG them all, And is there any POS = ALL like that? bcz my plan is after TAG the all grid then click a button, but the grid show uncertain. Thank you in advance

I'm avoiding to set TAG POS until 60 bcs sometime the page show 50 grid that resulting the last 10 POS #EANF#
Image https://imgur.com/a/iqYXRXj
Last edited by Cornysz on Wed Apr 15, 2020 9:36 pm, edited 1 time in total.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract uncertain DIV Class

Post by chivracq » Wed Apr 15, 2020 8:14 pm

Cornysz wrote:
Wed Apr 15, 2020 7:44 pm
Okay sorry for my bad english, it's make me hard to explain it :roll:
i hope you can understand this qt

So in this photo, sometimes the square/grid show in the page 50, or 55 or 60 (erratic) thats make me hard to TAG them all, And is there any POS = ALL like that? bcz my plan is after TAG the all grid then click a button, but the grid show uncertain. Thank you in advance

Code: Select all

https://imgur.com/a/iqYXRXj

Yeah, but ouf-ouf...!, you don't "need" to quote yourself again, this doesn't help for Readability of the Thread..., => can you edit/simplify your Post...?, for me to read...

You don't really need to quote at all to be honest, unless you are replying to a specific part of my Post, or if several (Advanced) Users were participating in your Thread... I do quote systematically because many Users "later" delete/mutilate their OP/Posts once they've got their Answer/Working Script, or keep editing their Posts as they "progress", which renders such Threads impossible/difficult to follow for other Users searching the Forum with a similar Qt/Scenario, but I don't delete my Posts, ah-ah...! :shock:

>>>

And hum, mentioned/explained in the Forum Rules, => can you upload your Screenshot directly to the Forum, without using some external Pix Hosting Site...?
Your OP contained a Screenshot already, that was "correctly" uploaded to the Forum, (or I wouldn't have approved your Post), why this time on 'imgur'...?

(But hum, there might be a Problem at this moment with the Forum with this Functionality, I tried a bit earlier to upload an Attachment and it was not working for me, and I don't know if the Pb is with the Forum itself and for all Users, or only for me... :? I was trying to reach the Forum Admin a bit earlier if he could check that, but he's not "reacting", so maybe you can try if it works for you..., and if it doesn't work for you also, then OK, leave the 'imgur' Screenshot for the moment...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: Extract uncertain DIV Class

Post by Cornysz » Wed Apr 15, 2020 9:37 pm

Fixed! I can't upload photo in Attachment menu, thats why i used imgur to use photo :D
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract uncertain DIV Class

Post by chivracq » Wed Apr 15, 2020 9:50 pm

Cornysz wrote:
Wed Apr 15, 2020 9:37 pm
Fixed! I can't upload photo in Attachment menu, thats why i used imgur to use photo :D

Alright, Thanks for the Edit and "simplifying" your previous Post... :D

And so, OK, so you also cannot upload an Attachment to the Forum, so I'm not the only one... OK then, nothing "we" can do at the moment, we have to wait until the Forum Admin sees my (internal) Msg... :wink:

>>>

OK, then about your Scenario, yeah well, then yep..., same Reply like before, simply record your Actions for 1 Block and loop your Script with "POS={{!LOOP}}", it will abort automatically if there is no "POS=51" for example... I don't see the Problem... :?
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: Extract uncertain DIV Class

Post by Cornysz » Thu Apr 16, 2020 2:40 am

Yes, im using POS = {{LOOP}} in my script, but i don't know how many i set for the loop play, if i set the loop 60 and the grid show 50, the last 10 will resulting #EANF#
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract uncertain DIV Class

Post by chivracq » Thu Apr 16, 2020 11:29 am

Cornysz wrote:
Thu Apr 16, 2020 2:40 am
Yes, im using POS = {{LOOP}} in my script, but i don't know how many i set for the loop play, if i set the loop 60 and the grid show 50, the last 10 will resulting #EANF#

Then tag first without extracting before extracting to let your Script "naturally" abort... :idea:

Or check first (using 'EXTRACT' + 'EVAL()') if the 'DIV' you want to extract does exist to save conditionally, or better, to force the Abort with 'MacroError()'.
Could also be done at the end of your Block, to already check on the Next Loop. :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: Extract uncertain DIV Class

Post by Cornysz » Thu Apr 16, 2020 11:48 am

Hmmm i'm still newbie, very hard to understand your answer :cry: , can you reexplain me with simple way? hehe i'm sorry :(
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract uncertain DIV Class

Post by chivracq » Thu Apr 16, 2020 11:55 am

Cornysz wrote:
Thu Apr 16, 2020 11:48 am
Hmmm i'm still newbie, very hard to understand your answer :cry: , can you reexplain me with simple way? hehe i'm sorry :(

All the Terms I used can be used to search the Forum and you'll find for each Area many relevant Threads..., or even in the Wiki..., 'MacroError()' for example is best explained in the Wiki already... :idea:

Quoting my own Sig, ah-ah...!:
- Script & URL help a lot for more "educated" Help...
No Script posted... => I only give Generic Answers... :|
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: Extract uncertain DIV Class

Post by Cornysz » Thu Apr 16, 2020 12:29 pm

chivracq wrote:
Thu Apr 16, 2020 11:55 am
No Script posted... => I only give Generic Answers... :|
Ohhh okay i'll give part of my script.

Code: Select all

SET !EXTRACT NULL
TAG POS={{!LOOP}} TYPE=A ATTR=DATA-SQE:link&&HREF:https://shopee.co.id/* EXTRACT=HREF
TAG POS={{!LOOP}} TYPE=DIV ATTR=class:_18SLBt EXTRACT=TXT
SET !VAR1 EVAL(" var exam='{{!EXTRACT}}'.replace(/\\n/g,''); exam;")
SET !VAR2 EVAL(" var exam='{{!VAR1}}'.replace(/\s\s+/g,''); exam;")
SET url {{!VAR2}}

ADD !EXTRACT {{Va2}}
SAVEAS TYPE=EXTRACT FOLDER=* FILE=kornis.csv
And then what should i do? Thanks in advance
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract uncertain DIV Class

Post by chivracq » Thu Apr 16, 2020 12:48 pm

Cornysz wrote:
Thu Apr 16, 2020 12:29 pm
Ohhh okay i'll give part of my script.

Code: Select all

SET !EXTRACT NULL
TAG POS={{!LOOP}} TYPE=A ATTR=DATA-SQE:link&&HREF:https://shopee.co.id/* EXTRACT=HREF
TAG POS={{!LOOP}} TYPE=DIV ATTR=class:_18SLBt EXTRACT=TXT
SET !VAR1 EVAL(" var exam='{{!EXTRACT}}'.replace(/\\n/g,''); exam;")
SET !VAR2 EVAL(" var exam='{{!VAR1}}'.replace(/\s\s+/g,''); exam;")
SET url {{!VAR2}}

ADD !EXTRACT {{Va2}}
SAVEAS TYPE=EXTRACT FOLDER=* FILE=kornis.csv
And then what should i do? Thanks in advance

Alright, at least now I can see and understand what you are doing...

Well, then, like already mentioned, add an extra 'TAG' (on the 'DIV', not on the 'Link') without any 'EXTRACT', before the 2 'TAG' Statements..., and if that 'DIV' is not clickable, that will abort your Script automatically...:

Code: Select all

TAG POS={{!LOOP}} TYPE=DIV ATTR=class:_18SLBt
SET !EXTRACT NULL
TAG POS={{!LOOP}} TYPE=A ATTR=DATA-SQE:link&&HREF:https://shopee.co.id/* EXTRACT=HREF
TAG POS={{!LOOP}} TYPE=DIV ATTR=class:_18SLBt EXTRACT=TXT
SET !VAR1 [...] etc...
And if the 'DIV' is clickable, you'll have to "find" some other non-clickable Element, or you'll have to implement one of the other Options I mentioned...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: Extract uncertain DIV Class

Post by Cornysz » Fri Apr 17, 2020 8:10 am

Thank you for your answer :D
Can i ask one more thing? What if i want to set the POS increment ( 1,2,3,4 .. 50), is it require javascript? if yes, how to do that?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Extract uncertain DIV Class

Post by chivracq » Fri Apr 17, 2020 12:32 pm

Cornysz wrote:
Fri Apr 17, 2020 8:10 am
Thank you for your answer :D

Okay..., but hum, not really clear if the one Line I added to your Script is "the" Solution and if your Script is working now...(?) :?

>>>
Cornysz wrote:
Fri Apr 17, 2020 8:10 am
Can i ask one more thing? What if i want to set the POS increment ( 1,2,3,4 .. 50), is it require javascript? if yes, how to do that?

Hahan...!?, I don't really understand your Qt and what you want exactly...(?) :?

The "POS increment" Functionality is done by looping your Script (using the 'Play (Loop)' Button in the iMacros Side-Panel) and using the '!LOOP' Built-in Var, like you are already doing, I understood from your "POS={{!LOOP}}"...

If you don't want to use that Built-in Looping Functionality for '.iim' Scripts, (or if you want to launch your Script from a '.bat' File for example if you want to use your OS Task Scheduler, which doesn't support Looping), then yep, it is possible to convert your '.iim' Script to a '.js' Script and you'll have to handle yourself the Looping Mechanism in the '.js' Script, and the Script can then be launched from the 'Play' Button in the iMacros Side-Panel (and not from the 'Play (Loop)' Button anymore)...

Creating '.js' Scripts is all documented in the Wiki and you'll find 100's or even 1000's of Script Samples from other Users on the Forum, maybe 50% of all Threads on the 'iMacros for FF' Sub-Forum are about a '.js' Script, that should give you "enough" Examples, ah-ah...! 8)

>>>

But be "careful" that you are "lucky" to still be using FF56, which still supports iMacros for FF v8.9.7 that you are using..., and which supports '.js' Scripts... If you ever update FF56 to FF[57-75+], you'll then have to use iMacros for FF v10.0.2 'Free'/'PE' which doesn't support '.js' Scripts anymore, and for which the 'Free' Version is now very limited in Functionality... (Max 50 Lines of Code and Looping = Max 100 Loops, etc...)
(Or you'll have to switch Browsers, Pale Moon (PM28) or Basilisk v2019/2020 for example still support iMacros v8.9.7 for FF.)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply