Copying/reading data and pasting it into forms

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
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
Yves w
Posts: 5
Joined: Tue Dec 06, 2011 4:47 pm

Copying/reading data and pasting it into forms

Post by Yves w » Tue Dec 06, 2011 11:03 pm

Hello,

I'm not sure if this question has been asked before, or not and if this is the right section. I'm new to iMacros and I would like to learn it, so I thought: "Why wouldn't I automate the captcha (some random numbers) at 'www.en.gratiswalliecard.nl/'?"

I looked at the wiki and found something about 'extract', which didn't work out, 'cause I messed up the code.

My plan was to read the numbers, parse them into for example 'x' and let iMacros type the value of x. So I looked at filling forms, but I read that it was paid if you would like to fill in an 'unset' value.

Could someone please help me? ^^ I'm using the free firefox-addon and I'm able to code some Java. Please don't mind my English; it's not my primary language.

Thanks in advance,

Yves.
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Copying/reading data and pasting it into forms

Post by Daniel, Tech Support » Wed Dec 07, 2011 12:49 pm

Hi Yves,

Thanks for your interest in iMacros! I would gladly help you to learn it better, but could you please come up with an example that wouldn't involve breaking captchas?
We do respect the choice not to allow automation that some of the website owners make.

Otherwise you're on the right path - copying text can be done using extraction, pasting - using the CONTENT= part of the TAG command.
Please have a look at the article here: http://wiki.imacros.net/TAG. And feel free to ask any further questions!

Best regards,
Daniel, iOpus Support
Yves w
Posts: 5
Joined: Tue Dec 06, 2011 4:47 pm

Re: Copying/reading data and pasting it into forms

Post by Yves w » Wed Dec 07, 2011 3:06 pm

Sorry, it was the first example that I thought of. Let's try to copy the value at 'http://www.random.org/', copy the result and past it into 'Max'.

Thanks for the support and iMacros is great! :)
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Copying/reading data and pasting it into forms

Post by Daniel, Tech Support » Thu Dec 08, 2011 8:28 am

Hi Yves,

Here is the macro:

Code: Select all

SET !EXTRACT_TEST_POPUP NO
URL GOTO=http://www.random.org/
FRAME F=1
TAG POS=1 TYPE=INPUT:BUTTON ATTR=ID:true-random-integer-generator-button
WAIT SECONDS=1
TAG POS=1 TYPE=SPAN ATTR=ID:true-random-integer-generator-result EXTRACT=TXTALL
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:true-random-integer-generator-max CONTENT={{!EXTRACT}}
Have a look and tell me if you have questions!

Best regards,
Daniel, iOpus Support
Yves w
Posts: 5
Joined: Tue Dec 06, 2011 4:47 pm

Re: Copying/reading data and pasting it into forms

Post by Yves w » Fri Dec 09, 2011 5:04 pm

Thanks, I'll take a look at it :). It's a lot different then Java, so I think that I will have some questions.
Yves w
Posts: 5
Joined: Tue Dec 06, 2011 4:47 pm

Re: Copying/reading data and pasting it into forms

Post by Yves w » Sat Dec 10, 2011 9:28 am

It's a lot harder then Java :P. Could you please explain the bold lines to me and check my explanation of the other ones?

SET !EXTRACT_TEST_POPUP NO
URL GOTO=http://www.random.org/ - Goes to random.org
FRAME F=1
TAG POS=1 TYPE=INPUT:BUTTON ATTR=ID:true-random-integer-generator-button -Clicks the button
WAIT SECONDS=1 - Waits 1 second
TAG POS=1 TYPE=SPAN ATTR=ID:true-random-integer-generator-result EXTRACT=TXTALL (how did you get the right ID?)
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:true-random-integer-generator-max CONTENT={{!EXTRACT}}


Edit: I found out how you got the 'true-random...-result'. You just got to record and select it. But how do you only copy parts of text? In this situation the min-input is 10, the max is 99. You only want to copy the last number (so if it's 76 then 6) and past it into min.
Last edited by Yves w on Tue Dec 13, 2011 5:06 pm, edited 1 time in total.
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Copying/reading data and pasting it into forms

Post by Daniel, Tech Support » Mon Dec 12, 2011 9:23 pm

Hi Yves,
It's a lot harderthen Java
Oh no, I think Java is harder! :)

SET !EXTRACT_TEST_POPUP NO - this is internal variable that tells iMacros not to show the extracted value in a popup. If you don't add it, the value will be shown in a popup, together with a tip on "SET !EXTRACT_TEST_POPUP NO" :).

FRAME F=1 - this tells iMacros to work on the 1st frame. This was generated automatically for me, when I was recording the macro

TAG POS=1 TYPE=SPAN ATTR=ID:true-random-integer-generator-result EXTRACT=TXTALL (how did you get the right ID?) - by recording my actions! Of course I could go into source code of the website and look it up, but that's too much work.

TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:true-random-integer-generator-max CONTENT={{!EXTRACT}} - in the previous line I extracted a value. When something is extracted, it is stored in the !EXTRACT variable. Here I assign web control's value to the value of !EXTRACT variable. When recording the macro I simply selected the control and then the only thing I changed is I added CONTENT={{!EXTRACT}}.

You understood everything else correctly!
But how do you only copy parts of text?
This is a bit more tricky. iMacros lets you use any programming language you want, in order to accomplish such tasks, here is why:
http://wiki.imacros.net/conditionals - the text there is about conditional statements (if/then/else), but it applies to any programming language constructs, like string functions etc. iMacros doesn't offer them, but let's you use your favorite programming language to do this. Here is some info on how: http://wiki.imacros.net/Web_Scripting.

And here are a few tutorials (I recommend to start with the recording tutorial!):
http://wiki.imacros.net/Tutorials

Best regards,
Daniel, iOpus Support
Yves w
Posts: 5
Joined: Tue Dec 06, 2011 4:47 pm

Re: Copying/reading data and pasting it into forms

Post by Yves w » Tue Dec 13, 2011 9:10 pm

Thanks :). I'll try to use iMacros and Java alongside. If I'll encounter other problems, I'll ask for help in this thread.
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Copying/reading data and pasting it into forms

Post by Daniel, Tech Support » Wed Dec 14, 2011 12:33 pm

Hi Yves, sure! We're here to help you! :)
Daniel, iOpus Support
Post Reply