I would like to check only one radio button (or checkbox), they are differents by the POS
TAG POS=1 TYPE=INPUT:RADIO FORM=ACTION:http://www.signup.com/index.php ATTR=NAME:my_input_radio CONTENT=YES
With POS randomly sets between 1 and 8
I would like to make it like that :
SET !VAR1 EVAL("var r=Math.floor(Math.random()*8+1);r;")
TAG POS={{!VAR1}} TYPE=INPUT:RADIO FORM=ACTION:http://www.signup.com/index.php ATTR=NAME:my_input_radio CONTENT=YES
But when I run the iMacros script, it searches for POS {{!VAR1}} and not POS 4 (for example, according that the precedent SET returned 4 to VAR1)
If there is just one then you can try this code and set the loop from 1 to 8.
TAG POS={{!LOOP}} TYPE=INPUT:RADIO FORM=ACTION:http://www.signup.com/index.php ATTR=NAME:my_input_radio CONTENT=YES
Related
I am automating the process of downloading information off of a site. As I can only search for (and then download) data from two days at a time, sometimes there is no data to be downloaded.In this instance, when the macro clicks the "download button, the following dialog box appears.
If there are listings to export, the macro proceeds through selecting a few options and downloading a file. However, if the dialog box above appears I would like the macro to skip the next few steps and proceed to a step several lines ahead. Is there any way to do this?
In brief, there can be several ways to do that which depend on your browser and 'iMacros'.
Here is one of them:
SET !EXTRACT_TEST_POPUP NO
SET msgText "No listings to export"
SET !ERRORIGNORE YES
TAG POS=1 TYPE=* ATTR=TXT:{{msgText}} EXTRACT=TXT
SET nextPos EVAL("'{{!EXTRACT}}'.match(/{{msgText}}/) ? '0' : '1';")
' your next steps
TAG POS={{nextPos}} TYPE=A ATTR=...
' ...
SET !ERRORIGNORE NO
If you play this code in loop mode, it's possible
to skip the next few steps and proceed to a step several lines ahead.
I am not good in coding but I managed to create this simple macro to extract email address from a specific page with iMacros for Firefox.
The macro works flawlessly... Except
There is a little problem with extracted data.
This is the extracted data:
" Some Name ","some#domain.comHello"
" Some Other Name ","other#domain.netThis"
" Any Name ","some#domain.com.twSomeothertext"
I believe there is a line break and/or pharagraph problem with the email fields. There are also 4 space at the begining and 2 spaces at the end of the Name field.
I want to get rid of it and fix the email extraction problem.
This is what i want:
"Some Name","some#domain.com"
"Some Other Name","other#domain.net"
"Any Name","some#domain.com.tw"
And that is the code
VERSION BUILD=8970419 RECORDER=FX
SET !TIMEOUT_STEP 0
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
TAB T=1
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV:nth-of-type(2)>DIV>DIV>DIV:nth-of-type(2)>DIV:nth-of-type({{!loop}})>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(2)>DIV>A>SPAN" BUTTON=0 MODIFIERS="ctrl"
TAB T=2
TAG POS=1 TYPE=DIV ATTR=ID:profile-display-name EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=1 TYPE=DIV ATTR=ID:profile EXTRACT=TXT
SET !VAR2 EVAL("'{{!EXTRACT}}'.match(/(([^<>()[\\]\\\.,;:\\s#\\\"]+(\\.[^<>()[\\]\\\.,;:\\s#\\\"]+)*)|(\\\".+\\\"))#((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))/g)[0];")
SET !EXTRACT NULL
SET !EXTRACT {{!VAR1}}[EXTRACT]{{!VAR2}}
SAVEAS TYPE=EXTRACT FOLDER=D:\ FILE=Contacts.txt
TAB T=1
TAB CLOSEALLOTHERS
'URL GOTO=javascript:window.scrollBy(0,2000)
Thanks for your help...
Try to make the folowing corrections:
SET !VAR1 EVAL("'{{!EXTRACT}}'.trim();")
and
TAG POS=1 TYPE=DIV ATTR=ID:profile EXTRACT=HTM
Thank you very much
I used the code
extract commented posts on facebook that are awesome
VERSION BUILD=8970419 RECORDER=FX
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
TAB T=1
SET !EXTRACT NULL
TAG POS={{!LOOP}} TYPE=SPAN ATTR=CLASS:UFICommentBody* EXTRACT=HTM
SET !VAR2 EVAL("'{{!EXTRACT}}'.match(/(([^<>()[\\]\\\.,;:\\s#\\\"]+(\\.[^<>()[\\]\\\.,;:\\s#\\\"]+)*)|(\\\".+\\\"))#((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))/g)[0];")
SET !EXTRACT {{!VAR2}}
SAVEAS TYPE=EXTRACT FOLDER=D:\ FILE=MAIL_FB.txt
I have an iMacros macro, which actually works like expected:
VERSION BUILD=8881205 RECORDER=FX
TAB T=1
URL GOTO=https://example.com/?page={{!LOOP}}
TAG POS=1 TYPE=BUTTON ATTR=TXT:
ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}} WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Excel
TAG POS=1 TYPE=A ATTR=TXT:Next<SP>Page<SP>>
But if any page gives any other HTTP status code as 200, my macro stops and then want to begin from the first page.
The question is: how can i achieve, that the macro doesn't stop, but just omit the page, which isn't available, in the best case after 5 access tryings.
Thank you!
Use this:
SET !ERRORIGNORE YES
This will keep the macro running and skip to the next page.
I have a long list of URLs and I want to extra the title from each one and save it into an Microsoft Excel file.
I tried looking around for the code to do this but could not find it. I'm using iMacros for Firefox.
I would suggest using internet explorer object along with MSHTML object library in excel VBA itself which may take off using 3rd party applications.
You need first the list of URLs in a file (one URL in each line). Let's call it listOfUrls.csv (save as from Excel or just use a plain text file). You place that file in the iMacros/Datasources folder.
Then the macro itself:
SET !DATASOURCE listOfUrls.csv
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
TAB T=1
URL GOTO={{!COL1}}
TAG POS=1 TYPE=TITLE ATTR=* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=openThisInExcel.csv
Now you have to play the macro as Loop (look for "Play (Loop)"). Play is as many times as URLs you have in the list (set that in "Max:"). Then the macro will take you to each URL and get the title and save it into openThisInExcel.csv. That's it.
You may also want to keep the URL in the result CSV (so you know which Title correspond to which URL). Add the following before the last line or the line before that one (depending on the column order you want):
ADD !EXTRACT {{!URLCURRENT}}
I'm writing an imacro script to automate tasks on firefox. The script works fine but sometimes it doesn't find the correct html.
How can I log to a txt file every time the script encounters an error?
Sample script:
VERSION BUILD=8601111 RECORDER=FX
TAB T=1
SET !TIMEOUT 4
SET !ERRORIGNORE YES
SET !DATASOURCE c:\myfile.csv
SET !DATASOURCE_COLUMNS 3
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
TAG POS=1 TYPE=INPUT:EMAIL FORM=ID:form0 ATTR=ID:Email CONTENT={{!COL1}} //lets assume the error is here, how can I log it ?
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:form1 ATTR=ID:Passwd CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:form2 ATTR=ID:PersistentCookie CONTENT=NO
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:form3 ATTR=ID:signIn
try to use profiler:
http://wiki.imacros.net/Performance_Profiler
other option is to convert your code to javascript or similar format and catch and save thrown errors::
http://wiki.imacros.net/Error_and_Return_Codes
you could use:
SET !FILE_PROFILER myprofile.xml
documented here: http://wiki.imacros.net/Performance_Profiler
..and than you have to write yourself a script that looks for errors in this file.