How to loop Css clicks and click subsequent CSS

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

Moderators: Community Moderators, iMacros Moderators

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.

How to loop Css clicks and click subsequent CSS

by Wheatlyos on Wed May 31, 2017 1:40 am

Config: Windows 10 64 bit, IMacro Enterprise v11.5.499_3066, Imacro Browser,
search.php
Essentially I want to click [All Results] and then once that’s done.. I then want to click the nav tabs (that open once I’ve clicked [ALL RESULTS]. Lets say once I click [All Results] it had 1400 different buttons I wanted to click, it doesn’t but lets say it did. How would I go about looping this?


The Css after the [ALL RESULTS] is…
#st > option:nth-child(1)
#st > option:nth-child(3)
#st > option:nth-child(1)
I have thus far…
VERSION BUILD=11.5.499.3066
TAB T=1
TAB CLOSEALLOTHERS
SET !PLAYBACKDELAY 0.2
URL GOTO=http://forum.imacros.net/search.php
TAG SELECTOR="#st" CONTENT=%1
TAG POS=((!LOOP)) TYPE=SELECT ATTR=CLASS* EXTRACT=TXT <- Is there a way to do this for CSS like increasing in a variable or somehow not having to type the exact CSS name and all for each of them? As I want it to continually loop click TAG SELECTOR="#st" CONTENT=%1 and then click subsequent CSS. Thanks in advance, I appreciate it.
Wheatlyos
 
Posts: 2
Joined: Wed May 31, 2017 12:55 am

Re: How to loop Css clicks and click subsequent CSS

by chivracq on Wed May 31, 2017 5:08 am

Wheatlyos wrote:Config:
Code: Select all
Windows 10 64 bit, IMacro Enterprise v11.5.499_3066, Imacro Browser,

Code: Select all
http://forum.imacros.net/search.php

Essentially I want to click [All Results] and then once that’s done.. I then want to click the nav tabs (that open once I’ve clicked [ALL RESULTS]. Lets say once I click [All Results] it had 1400 different buttons I wanted to click, it doesn’t but lets say it did. How would I go about looping this?

The Css after the [ALL RESULTS] is…
Code: Select all
#st > option:nth-child(1)
#st > option:nth-child(3)
#st > option:nth-child(1)

I have thus far…
Code: Select all
VERSION BUILD=11.5.499.3066
TAB T=1
TAB CLOSEALLOTHERS
SET !PLAYBACKDELAY 0.2
URL GOTO=http://forum.imacros.net/search.php
TAG SELECTOR="#st" CONTENT=%1
TAG POS=((!LOOP)) TYPE=SELECT ATTR=CLASS* EXTRACT=TXT
<- Is there a way to do this for CSS like increasing in a variable or somehow not having to type the exact CSS name and all for each of them? As I want it to continually loop click TAG SELECTOR="#st" CONTENT=%1 and then click subsequent CSS. Thanks in advance, I appreciate it.

Hum..., you could add a Question Mark to your Thread Title, I thought you were sharing a HowTo/Tutorial... :idea:

Well, I don't "have" this 'TAG SELECTOR' Mode which I thought was only implemented in iMacros v8.4.4 for CR, but in iMB v11.5 as well, looks from your FCI, and I only/mostly use iMacros for FF (v8.8.2 and v8.9.7) where this Mode has not been implemented (yet...!?) but I reckon it works a bit like the 'EVENT' Mode with 'SELECTOR', then I would think you can use a Var for the 'n' part in the ':nth-of-type(n)' part of the Selector like:
Code: Select all
TAG SELECTOR="#st:nth-of-type({{!LOOP}})" CONTENT=%1

Even for the "first" Element which doesn't have the ':nth...' part, you can always add a ':nth-of-type(1)' to it.
(It works for the 'EVENT' Mode and I use this "Technique" myself, I would expect it to work as well for the 'TAG SELECTOR' Mode...)
(But this is a "bad" Example on your Example Page as there is only one '#st' Element, the 2nd DDLB (for 'Post Time', 'Author' etc...) is called '#sk', etc...)

But if you want to loop through the different Options in the DDLB, then you can use a Var in the 'CONTENT' part like:
Code: Select all
TAG SELECTOR="#st" CONTENT=%{{!LOOP}}
(The 'Select by Index' Selector (%) needs to be left outside the Var, like documented in the Wiki...)

Not sure I exactly understood your Qt though, ah-ah...! (I can't really place the "1400 different buttons" part in your Scenario, at least on this 'Search' Page...) Can you give otherwise more Details about what exactly you want...?

Hum..., and if your "Goal" is to extract all the Options in the DDLB, you can simply use the 'EXTRACT=TXTALL' Built-in Mechanism... (as opposed to 'EXTRACT=TXT' which will extract the currently selected (= visible) Option in the DDLB...)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6486
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How to loop Css clicks and click subsequent CSS

by serbeer on Tue Jun 06, 2017 8:44 am

chivracq wrote:Well, I don't "have" this 'TAG SELECTOR' Mode which I thought was only implemented in iMacros v8.4.4 for CR, but in iMB v11.5 as well, looks from your FCI, and I only/mostly use iMacros for FF (v8.8.2 and v8.9.7) where this Mode has not been implemented (yet...!?)


Why chivracq, according to this http://wiki.imacros.net/TAG Firefox plugin has selector mode implemented:
Code: Select all
TAG SELECTOR="[selector_expression]" [CONTENT=some_content]

Now, I myself I only use POS and XPATH modes so far I must admit, and they always did the trick for me, but I always thougth that would have SELECTOR mode available as well if ever becomes needed, so was surprised by your reply.
serbeer
 
Posts: 35
Joined: Thu Sep 10, 2015 10:36 pm

Re: How to loop Css clicks and click subsequent CSS

by chivracq on Tue Jun 06, 2017 9:02 am

serbeer wrote:
chivracq wrote:Well, I don't "have" this 'TAG SELECTOR' Mode which I thought was only implemented in iMacros v8.4.4 for CR, but in iMB v11.5 as well, looks from your FCI, and I only/mostly use iMacros for FF (v8.8.2 and v8.9.7) where this Mode has not been implemented (yet...!?)


Why chivracq, according to this http://wiki.imacros.net/TAG Firefox plugin has selector mode implemented:
Code: Select all
TAG SELECTOR="[selector_expression]" [CONTENT=some_content]

Now, I myself I only use POS and XPATH modes so far I must admit, and they always did the trick for me, but I always thougth that would have SELECTOR mode available as well if ever becomes needed, so was surprised by your reply.

Ah-han...!, oh...!, then it's possible that it's maybe implemented in v9.0.3 for FF which I never installed/tested, I only checked/tested in v8.9.7 for FF (+ v8.8.2 for FF which is my "Prod" Environment, but I knew it wouldn't be present in this Version)...

Oh yeah...!, and when I had typed my previous Reply, I had checked the Wiki and the Release Notes for v9.0.3 for FF don't mention anything about this Mode, while it is neatly documented in the Released Notes for v8.4.4 for CR...:
Version History (iMacros for FF)

2016-08-10 V9.0.3 => Download now
This version is a major upgrade to add compatibility with Multi Process Firefox released in Firefox 48 (codename Electrolysis, e10s). Unfortunately, this change imposes the following limitations:
SCREENSHOT TYPE=BROWSER is no longer possible,
SAVEAS TYPE=CPL is not available anymore,
File Upload in the TAG command cannot be supported.
CLICK (X/Y) record mode is now deprecated, use EVENT mode instead. However, existing macros that contain CLICK commands can be replayed.
The following were never officially supported and had to be removed as well, since Firefox no longer allows access to the page DOM from the browser context (only frame scripts can do so now)
No access to webpage DOM from javascript in .js files (window, content objects) or macros (URL GOTO=javascript:...),
imns (iMacros namespace) is no longer accessible.

Version History (iMacros for CR)

2016-06-20 V8.4.4 Download now
Added: new recording mode EVENT
Added: TAG SELECTOR command, to localize element using CSS selectors
Several bug fixes


But hum..., pity @OP never followed up on this Thread, that was an interesting "Case", ah-ah...!
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6486
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How to loop Css clicks and click subsequent CSS

by Wheatlyos on Tue Jun 06, 2017 7:50 pm

Hi, sorry for the late reply. Your solution worked so thanks heaps. I haven't really been able to dig into Imacro as much as I would have liked. I am impressed though. I can see there is a bit of a steep learning curve and a lot of potential. For me I feel like it would only take a matter of months before I have mastered some of the more basic functions and that is actually really awesome. I understand this query is resolved, but one query I do have is how does one utilise this for more than one website? So lets say I wanted to use the above example in two webpages. How would you go about that?
Wheatlyos
 
Posts: 2
Joined: Wed May 31, 2017 12:55 am

Re: How to loop Css clicks and click subsequent CSS

by chivracq on Tue Jun 06, 2017 8:16 pm

Wheatlyos wrote:Hi, sorry for the late reply. Your solution worked so thanks heaps. I haven't really been able to dig into Imacro as much as I would have liked. I am impressed though. I can see there is a bit of a steep learning curve and a lot of potential. For me I feel like it would only take a matter of months before I have mastered some of the more basic functions and that is actually really awesome. I understand this query is resolved, but one query I do have is how does one utilise this for more than one website? So lets say I wanted to use the above example in two webpages. How would you go about that?

Oh..., good, nice to see you back...! :D
And glad to hear that "my Solution" worked, ah-ah...!

:idea: But hum, to finish your Thread a bit "neatly" and useful for other Users, you would be expected to shared your final Script, then we can talk about asking other Qt's, either in this same Thread if you feel it's related and a Follow-up Qt on your OP or you can open some other Thread (in the correct Sub-Forum, of course...!)... :idea:

And further about what you consider the 'steep learning curve" for iMacros, I don't really agree to be honest, iMacros has a very intuitive way to use it, you don't need to be a Programmer, you just record your Actions on some Site, you replay, oops...!, not completely OK, you look at the recorded Code, make some little Edits thanks to the nearly perfect Wiki, and that's it...! It's a very easy Programming-Language, very Intuitive..., too easy and too intuitive actually, too many Kids use it, ah-ah...! It took me 30 min 10 years ago when I discovered it during some Game/Competition I was playing to make my perfect Script and win the big Price and 10 years later my old Script still works perfectly and I still win every year, oops...!
The only Quality you need with iMacros is to be a little bit Creative... (and to read the Wiki of course to know what Commands are available and how they work)...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6486
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: No registered users and 4 guests

-->