Extract - Compare - Fill

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
Manoj
Posts: 5
Joined: Sat May 21, 2011 3:35 am

Extract - Compare - Fill

Post by Manoj » Sat May 21, 2011 3:56 am

Hi guys,

Please help me to do this task.

I need to login to a website which asks a captcha question everytime. But there is a limited set of questions(say 20 to 25) which have been repeatedly asked. What i want to do is extract the question from the website and compare the question with a table(consisting of the question in one column and answer in other) and fill the answer in the textarea automatically . Is that possible through imacros?

Here is a sample html source of the question:

Code: Select all

<span id="captcha">
  <input type="hidden" value="173" name="cap_id" id="cap_id">
  <p>What is 2+3?</p>

  <label for="cap_answer">Answer:</label>
  <input type="text" size="20" name="cap_answer" maxlength="20" id="cap_answer">
</span>
I want to extract the question "What is 2+3?" from the page and compare the extracted data with a table containing the questions and answers and fill the answer in the answer column.

As i am a noob in everything, someone please explain me in detail if you have a soultion. Thank you very much
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Extract - Compare - Fill

Post by siniy » Sat May 21, 2011 2:04 pm

1.iim:

Code: Select all

SET !EXTRACT NULL
TAB CLOSEALLOTHERS
TAB T=1
SET !REPLAYSPEED MEDIUM
'Your example file
URL GOTO=file:///C:/Users/Admin/Desktop/question.html
TAG POS=1 TYPE=P ATTR=TXT:* EXTRACT=TXT
TAB OPEN
TAB T=2
'File with answers table
URL GOTO=file:///C:/Users/Admin/Desktop/answers.html
TAG POS=1 TYPE=P ATTR=TXT:{{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT
TAB CLOSE
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:cap_answer CONTENT={{!EXTRACT}}
answers.html:

Code: Select all

<p>What is 3+3?</p> <span>6</span>
<p>What is 2+3?</p> <span>5</span>
<p>What is 4+3?</p> <span>7</span>
Manoj
Posts: 5
Joined: Sat May 21, 2011 3:35 am

Thank you very much

Post by Manoj » Sat May 21, 2011 3:20 pm

It works like a charm. Great Thanks to you. :D
spondodge
Posts: 3
Joined: Sat Jun 02, 2012 8:06 pm

Re: Extract - Compare - Fill

Post by spondodge » Sat Jun 02, 2012 8:10 pm

Hi, i know this is an old post but the code almost does exactly what I want. What would i change to make it click a "ANSWER_ID:123456" instead of input text?

Same setup really, asks a question and the answer id's are always the same for each question. So I could create a file with question and answer id, just need a tag that will click the right answer.

Cheers in advance if you can help
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Extract - Compare - Fill

Post by siniy » Sat Jun 02, 2012 8:38 pm

It is hard to tell without html code. I assume you are talking about radiobutton.

Code: Select all

TAG POS=1 TYPE=INPUT:RADIO  ATTR=ID:ANSWER_ID*{{!EXTRACT}} CONTENT=YES
Or

Code: Select all

TAG POS=1 TYPE=INPUT:* ATTR=ID:*{{!EXTRACT}} CONTENT=YES
spondodge
Posts: 3
Joined: Sat Jun 02, 2012 8:06 pm

Re: Extract - Compare - Fill

Post by spondodge » Sat Jun 02, 2012 10:58 pm

thanks for the reply, html is 4 buttons, the button order switches around when questions are repeated but answer id always pairs with question id, i tried triggering solely on answer id with "TAG POS=1 TYPE=DIV ATTR=ANSWER_ID:987654" which clicked on the answers but i had to loop a list of answer ids until it detetected the correct answer_id and clicked. It took ages to cycle through all of them, so i figured this method would be quicker. Heres some html from the flash quiz game:


<div class="question-inner">
<div class="question-text" question_id="123456789">What date did the mary anne sail from america?</div>
</div>


<div data-role="button" class="answer A1" answer_id="123456" cor="987654">
<div class="answer-num">1</div>
<span class="answer-text">Answer text goes here.</span>
</div>

<div data-role="button" class="answer A2" answer_id="234567" cor="987654">
<div class="answer-num">2</div>
<span class="answer-text">Alternative answer text</span>
</div>

<div data-role="button" class="answer A3" answer_id="345678" cor="987654">
<div class="answer-num">3</div>
<span class="answer-text">Answer text three</span>
</div>

<div data-role="button" class="answer A4" answer_id="456789" cor="987654">
<div class="answer-num">4</div>
<span class="answer-text">Final answer to question text</span>
</div>
spondodge
Posts: 3
Joined: Sat Jun 02, 2012 8:06 pm

Re: Extract - Compare - Fill

Post by spondodge » Tue Jun 05, 2012 3:46 pm

Iv been trying to get this code working since last i posted and it just doesn't seem to work properly, im no coder and have searched many threads looking for the fastest way to check a question against a answer and click the correct tag id. It would appear what im after is a javascript to search for keywords in the question then select the correct TAG CLICK answer_id. Im not sure how to use javascript with imacros, i see you could save a file as .js and put the code in it but how would I then tie it all together and trigger it?

Originally i was using a looped script like this:
VERSION BUILD=5100505 RECORDER=CR
SET !TIMEOUT_STEP 0
SET !ERRORIGNORE YES
SET !ERRORCONTINUE YES
FRAME F=2
TAG POS=1 TYPE=DIV ATTR=ANSWER_ID:132465
TAG POS=1 TYPE=DIV ATTR=ANSWER_ID:654987
TAG POS=1 TYPE=DIV ATTR=ANSWER_ID:524562
TAG POS=1 TYPE=DIV ATTR=ANSWER_ID:987654
TAG POS=1 TYPE=DIV ATTR=ANSWER_ID:456789
TAG POS=1 TYPE=DIV ATTR=ANSWER_ID:123465

because it was sequential though it was not getting the answers quick enough by looping it.
Post Reply