How to loop in files using imacros - imacros

I am trying to use imacros to upload videos to let's say youtube.
Currently it looks like this -
VERSION BUILD=8961227
RECORDER=FX
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=youtube
UPLOAD URL TAG POS=1 TYPE=A ATTR=TXT:Upload<SP>new<SP>videos
TAG POS=1 TYPE=INPUT:FILE FORM=ID:upload_form_basic ATTR=ID:file_basic CONTENT=C:\Users\Administrator\Desktop\UPLOAD<SP>Test\({{!LOOP}}).mp4
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:video_keywords CONTENT=
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:terms CONTENT=YES
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:upload_form_basic ATTR=ID:upload_submit
WAIT SECONDS=20
The problem i am facing here is -
I have let's say 50 videos saved in this folder with random names all .mp4 format.
I want imacros to wait stipulated time frame before it comes back to this loop and pick the NEXT file in the same folder. I am unable to do that.
Can anyone help me how should i make imacros pick the next file in the second loop. ?

Hi. Simply create a file list then use it in the loop.
Move createlist.bat on your video folder and run once.
#echo off
dir /b /s *.mp4 > %USERPROFILE%\Documents\iMacros\Datasources\list.txt
By the way it will create with all subdirectories (!) on your video folder. If you want non recursive way use it:
#echo off
del %USERPROFILE%\Documents\iMacros\Datasources\list.txt
for /f "usebackq TOKENS=*" %%i in (`dir /b *.mp4`) do (echo %%~fnxi) >> %USERPROFILE%\Documents\iMacros\Datasources\list.txt
Now use the list.txt as datasource. The list.txt has only 1 column. You can call each line using {{!COL1}}}. For more info Form Filling.
SET !DATASOURCE list.txt
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
'.....
'..... URL GOTO www.yoursite...
'..... Fill here according to your site
'.....
'.....
TAG POS=1 TYPE=INPUT:FILE FORM=ID:upload_form_basic ATTR=ID:file_basic CONTENT={{!COL1}})
'.....
'.....

The {{!LOOP}}.FILE EXTENSION works for me with sequential numbers within my file names.

Related

Clicking almost 2 identical urls with imacro

I am working on a imacro script and i am just stuck with it and can't figure out what i am doing wrong.
It is a macro thát visits a certain forum part and it needs to click 2 links.
They are almost identical except for 1 part.
It is used to download attachments.
Code i got at the moment:
TAG POS=1 TYPE=A ATTR=ID:aid* EXTRACT=href
tab open
tab t=2
url goto={{!EXTRACT}}
TAB CLOSE
TAG POS=2 TYPE=A ATTR=ID:aid* EXTRACT=href
tab open
tab t=2
url goto={{!EXTRACT}}
I also tried it like this:
TAG POS=1 TYPE=A ATTR=HREF:*linkhere*/forum.php?mod=attachment&aid=* EXTRACT=href
tab open
tab t=2
url goto={{!EXTRACT}}
SET !EXTRACT NULL
TAB CLOSE
TAG POS=2 TYPE=A ATTR=TXT:*.pdf EXTRACT=HREF
SET link EVAL("'{{!EXTRACT}}'.match(/(http.*)\./)[1];")
URL GOTO={{link}}
but still no luck.
As you see 1 file is a image, but the 2nd file can be a pdf or zip/rar file.
Most of them are pdf tough.
Hopefully can point me in the right direction with this as i got no clue anymore...
Why don't you simply save the files directly?
Do you need to open them in a different tab?
TAG POS=1 TYPE=IMG ATTR=HREF:http://*.jpg CONTENT=EVENT:SAVEITEM
TAG XPATH="/html/body/div[1]/form/div[3]/div/h2/span[2]/a[1]" CONTENT=EVENT:SAVETARGETAS
or something like that depending on what you have there.
I prefer to refer items by XPATH, but that's just me

go to the next step if {{!EXTRACT}} is true

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

Imacros get downloaded image file name in firefox

I am using imacros in firefox and saving some images and I want to be able to store the saved images names in a variable, but it seems that the code at the end of my code below
SET !EXTRACT {{!DOWNLOADED_FILE_NAME}}
PROMPT {{!DOWNLOADED_FILE_NAME}}
does not work in firefox, only in ie, does anyone no how I can save the filename of the image into a variable for latter use in my imacros script in firefox browser, I prefer not to use ie browser if at all possible
thanks
VERSION BUILD=8881205 RECORDER=FX
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 10
SET !TIMEOUT_TAG 0
SET !WAITPAGECOMPLETE YES
SET !EXTRACT_TEST_POPUP NO
TAB T=1
URL GOTO=http://www.somerandomsite.com
TAG POS=5 TYPE=INPUT:SUBMIT ATTR=*
TAG POS=1 TYPE=IMG ATTR=SRC:http://*.jpg
ONDOWNLOAD FOLDER=C:\Users\pb\Pictures\produts FILE=* WAIT=YES
'Download the picture
TAG POS=1 TYPE=IMG ATTR=SRC:http://*.jpg CONTENT=EVENT:SAVEITEM
TAG POS=2 TYPE=DIV ATTR=CLASS:iv_thumb_image&&TXT:
ONDOWNLOAD FOLDER=C:\Users\pb\Pictures\produts FILE=* WAIT=YES
'Download the picture
TAG POS=1 TYPE=IMG ATTR=SRC:http://*.jpg CONTENT=EVENT:SAVEITEM
SET !EXTRACT {{!DOWNLOADED_FILE_NAME}}
PROMPT {{!DOWNLOADED_FILE_NAME}}

use a webbased datafile with SET !DATASOURCE

How can i use a webbased file ie csv file like csv file link with the SET !DATASOURCE command in imacros,the reason is that i want to use the webbased file?
SET !DATASOURCE profile1.csv
SET !DATASOURCE_COLUMNS 4
SET !DATASOURCE_LINE {{!LOOOP}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:textbox1 CONTENT={{!COL0}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:textbox2 CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:textbox3 CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:textbox4 CONTENT={{!COL3}}
This example reads CSV file from Hard Drive placed in Datasource folder. As for webased file the only idea I have right now is if you had something like a sheet in the web browser window. From it iMacros can read the whole table and use those data . But without JS scripting it can't be done easily.
Make an iMacros code that downloads that file from a webserver to your hard drive/datasource folder.

Imacros help, script was working but not now

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