There are 10 li tags in an html. I need the number to use it with a loop in a vbs file.
I tried this simple code but it didn't work, even in firefox extension
URL GOTO=javascript:document.getElementsByClassName('movableListItem').length;
One can try the code below to set the built-in variable !EXTRACT to the number of image tags in a document. And your question is similar.
SET !EXTRACT_TEST_POPUP NO
URL GOTO=javascript:{window.document.getElementsByTagName("img").length}
URL GOTO=javascript:{window.history.back()}
TAG POS=1 TYPE=HTML ATTR=* EXTRACT=TXT
BACK
Imacros can do it but you need to make a loop and catch the first error. It's kinda complicated for just this simple question but in Selenium IDE just do this:
Command: storeCssCount
Target : css=a
Value : n
And that's all. A single line of code
Related
I want to extract the title from an HTML code, using Imacros and RegEx, the title is wrapped in some code that I want to filter out, I don't know how to use EVAL neither RegEx, I just found some RegEx that worked with my code, so it extracts the title from other codes,
but I am not sure how to use it with Imacros, appreciate it if anyone knows how to make it work, whether with RegEx or other ways.
Here is the html part:
<a data-test-id="search-guide" href="" title="Search for "skin care routine""><div
class="Jea Lfz XiG fZz gjz qDf zI7 iyn Hsu" style="white-space: nowrap; background-color: rgb(115,
115, 115);"><div class="tBJ dyH iFc MF7 erh tg7 IZT mWe">Routine</div></div></a>
the part from the title I want is: skin care routine
the RexEx part that I use:
title="Search for "([^"]*)"
and here is my Imacros:
TAG POS=3 TYPE=a ATTR=data-test-id:search-guide EXTRACT=href
SET !VAR1 EVAL('s = '{{!EXTRACT}}'[title='Search for "([^']*)"]')
PROMPT {{!EXTRACT}}
I get an error on the EVAL Line:
wrong format of SET command, line 15 (Error code: -910)
OK, I got it working, Here is the working code:
TAG POS=3 TYPE=A ATTR=data-test-id:search-guide EXTRACT=TITLE
SET !VAR1 EVAL("\"{{!EXTRACT}}\".substr(10,100);")
PROMPT {{!VAR1}}
Several "Mistakes" in your Script and Approach indeed...
'EXTRACT=HREF' won't get you anywhere, => simply use directly 'EXTRACT=TITLE' + 'EVAL()' (with 'replace()' if you don't mind keeping the Double Quotes, or 'split()' if you want to get rid of them)...
(Much easier without 'RegEx' anyway...)
(Spell "iMacros" correctly (x5) + Add a Question Mark to your Title (you are not sharing a 'HowTo'...) + Mention your FCI if you need me to "elaborate" in more Details...)
I'm entirely new to iMacros, and I'm trying to get iMacros to extract the email address that appears when you click "reply" on ads like these. (Link is "dead"...)
The only thing I have is:
VERSION BUILD=10021450
URL GOTO=https://losangeles.craigslist.org/sfv/res/d/need-extra-money/7027377618.html
TAG POS=1 TYPE=BUTTON ATTR=TXT:reply
I have tried simply using wildcards, which doesn't work.
I found the answer somehow:
TAG POS=1 TYPE=INPUT ATTR=CLASS:anonemail EXTRACT=TXT
I am using iMacros to try and get the text from each list item. My simple HTML looks like this...
<ul id="fruit_list">
<li>Apple</li>
<li>Pear</li>
<li>Banana</li>
<li>Grape</li>
</ul>
And my iMacros script like this..
TAB T=1
URL GOTO=file:///C:/test.html
TAG POS=1 TYPE=UL ATTR=ID:fruit_list EXTRACT=TXT
The result I get back is ...
AppleApplePearAppleApplePearBananaAppleApplePearAppleApplePearBananaGrape
When what I am expecting is...
Apple Pear Banana Grape
Can anyone show me what I am doing wrong?
There seems to be no easy EXTRACT Option that covers unordered lists that way... The simplest way to go about this is probably to extract the HTML code and parse that in Javascript with SET/EVAL.
It could look like this
TAG POS=1 TYPE=UL ATTR=ID:fruit_list EXTRACT=HTM
SET neat_list EVAL("var e_s = '{{!EXTRACT}}'; e_s.substring(e_s.indexOf('<li>'), e_s.lastIndexOf('<\\/li>')).replace(/(<li>|<\\/li>)/g, '').replace(/ +/g, ' ');")
PROMPT {{neat_list}}
Using Regex to drop all the HTML Tags and additional whitespace to just keep the LI-Item Data you wanted.
i'm new here and newbie in imacros and javascript
I have made a script that will extract a random word from a page with a regex syntax.
The script is working fine, is going to page.. is search for the word and if is there will extract the word.
But i need that the script is to refresh the page until the word is found and after that to run the second imacro script
VERSION BUILD=8961227 RECORDER=FX
SET !TIMEOUT 1
SET !ERRORIGNORE YES
TAB T=1
URL GOTO=url
SEARCH SOURCE=REGEXP:"raspuns":\[\"(.[^"]*)" EXTRACT=$1
SET !VAR1 {{!EXTRACT}}
and if the word is found run the second script (if not refesh)
TAB T=2
URL GOTO=url
TAG POS=1 TYPE=TEXTAREA ATTR=AUTOCOMPLETE:off CONTENT={{!EXTRACT}}
TAG POS=1 TYPE=BUTTON ATTR=CLICK:sendMessage()&&CLASS:go&&TXT:
anyone can help me with this?
Not super sure if I know exactly what you want and as it is imacros there are some weird workarounds but this might help you
VERSION BUILD=8961227 RECORDER=FX
SET !TIMEOUT 1
SET !ERRORIGNORE YES
TAB T=1
URL GOTO=url
SEARCH SOURCE=REGEXP:"raspuns":\[\"(.[^"]*)" EXTRACT=$1
SET !VAR0 raspuns
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL
SET !VAR2 EVAL("('{{!VAR0}}' == '{{!VAR1}}') ? 1 : 0;")
TAB T=2
URL GOTO=url
TAG POS={{!VAR2}} TYPE=TEXTAREA ATTR=AUTOCOMPLETE:off CONTENT={{!EXTRACT}}
TAG POS={{!VAR2}} TYPE=BUTTON ATTR=CLICK:sendMessage()&&CLASS:go&&TXT:
As you didnt give a url its very hard for me to test, but point is, if if takes the word youre looking for, raspun, it will set the TAG position to 1, therefore tagging what you need, but if it doesnt, it will set the TAG pos = 0, therefore just passing through the code, hope that helps
This line was working before but now it doesn't extract the text, I guess this is happening because it is clicking inside the box. This only happen when I use Firefox, using Internet Explorer is ok.
VERSION BUILD=8021970
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=http://www.fakemailgenerator.com/
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:emailForm ATTR=ID:fName&&VALUE:* EXTRACT=TXT
it looks like the value you need is disappear when imacros tries to scrape it, but you can use this code to get email:
URL GOTO=http://www.fakemailgenerator.com/
TAG POS=1 TYPE=span attr=id:cxtEmail EXTRACT=TXT
or you can scrape htm of your tag and parse it to get value attribute