How to get keyword from page source?

Discussions and Tech Support related to the iMacros Google Chrome extension.
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
weilies
Posts: 6
Joined: Wed Aug 16, 2017 2:15 am

How to get keyword from page source?

Post by weilies » Wed Aug 16, 2017 2:24 am

Good day gurus,

i have a use case where i have to input 4 captcha characters in order to proceed to next page and the 5 image-text are in code below

Code: Select all

<td><div id="img1"><img width="35" height="55" src="images/cap/1.png"></div></td>
<td><div id="img2"><img width="35" height="55" src="images/cap/2.png"></div></td>
<td><div id="img3"><img width="35" height="55" src="images/cap/3.png"></div></td>
<td><div id="img4"><img width="35" height="55" src="images/cap/4.png"></div></td>
<td><div id="img5">&nbsp;</div></td>
i have my imacro script below

Code: Select all

VERSION BUILD=844 RECORDER=CR
URL GOTO=my_url
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:mainf ATTR=NAME:capcha CONTENT=1234
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:mainf ATTR=*
  • How can i program the script to extract "1", "2", "3", "4" from the .png file and concatenate them into a string "1234"
  • And also how to program an IF/ELSE if the 5th return null, only concatenate first 4 characters and put in the macro script
Thanks a lot
chivracq
Posts: 8786
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to get keyword from page source?

Post by chivracq » Wed Aug 16, 2017 3:04 am

weilies wrote:Good day gurus,

i have a use case where i have to input 4 captcha characters in order to proceed to next page and the 5 image-text are in code below

Code: Select all

<td><div id="img1"><img width="35" height="55" src="images/cap/1.png"></div></td>
<td><div id="img2"><img width="35" height="55" src="images/cap/2.png"></div></td>
<td><div id="img3"><img width="35" height="55" src="images/cap/3.png"></div></td>
<td><div id="img4"><img width="35" height="55" src="images/cap/4.png"></div></td>
<td><div id="img5">&nbsp;</div></td>
i have my imacro script below

Code: Select all

VERSION BUILD=844 RECORDER=CR
URL GOTO=my_url
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:mainf ATTR=NAME:capcha CONTENT=1234
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:mainf ATTR=*
  • How can i program the script to extract "1", "2", "3", "4" from the .png file and concatenate them into a string "1234"
  • And also how to program an IF/ELSE if the 5th return null, only concatenate first 4 characters and put in the macro script
Thanks a lot
Oh yeah...!, (F)CIM...! :mrgreen: (As a start, for me to read, read my Sig...)
=> FCI: iMacros for CR v8.4.4, CR60...?, OS...?

And hum, the 'iMacros for CR' Sub-Forum means your Script works in other Browsers but fails in CR with iMacros for CR only... Not the case I would think, especially if you don't even mention your FCI..., try to select the correct Sub-Forum next time you open a Thread... (And no need to duplicate this time of course...)

But OK, Thread Title is perfect I would think, descriptive at least, Script and Source posted, no URL though, OK, I'll see once I'll have a chance to read after you'll have posted your FCI...
Oh, but hum, I think I saw "Captcha" in my quick Scan, then hum..., I don't promise anything, I normally don't help Users for Captcha, sorry...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 8786
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to get keyword from page source?

Post by chivracq » Wed Aug 16, 2017 3:13 am

Hum, read your Post anyway, grrr...!, pity it's about Captcha, quite interesting Case though..., but fairly easy to solve indeed, ah-ah...!
I won't help you "directly" as I don't help Users for Captchas, but hum, try a bit your best and I might still help a little bit if you really get stuck... (and really try your best, ah-ah...!)

But hum, your Thread Title is less "good" than I thought, "keyword" and "page source" are not very relevant Keywords about the Content (of the Thread)..., even if tja...!, everything on a Web-Site/Web-Page is also defined in the "page source", but this also applies to absolutely everything on Internet, ah-ah...!
Last edited by chivracq on Wed Aug 16, 2017 3:23 am, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
weilies
Posts: 6
Joined: Wed Aug 16, 2017 2:15 am

Re: How to get keyword from page source?

Post by weilies » Wed Aug 16, 2017 3:17 am

Sorry I am new to imacros...
I posted in this forum coz I am using chrome add-on, nothing to deal with other browser as I don't know if it works on other platform. Not my concern

Detail: Window 10, chrome v 56, 64 bits, imacros chrome add-on should be latest coz I installed today from chrome store
chivracq
Posts: 8786
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to get keyword from page source?

Post by chivracq » Wed Aug 16, 2017 3:33 am

weilies wrote:Sorry I am new to imacros...
I posted in this forum coz I am using chrome add-on, nothing to deal with other browser as I don't know if it works on other platform. Not my concern

Detail:

Code: Select all

Window 10, chrome v 56, 64 bits, imacros chrome add-on
should be latest coz I installed today from chrome store
OK, => FCI:

Code: Select all

iMacros for CR v8.4.4, CR56-x64, Win10-x64.
Well "not your concern", it is "our concern" that Users post on the correct Sub-Forum, and other Users search the Forum with a similar Case/Qt, looking for Solutions...

But OK, now you try your best, ah-ah...! :idea:

Interesting Captcha System btw, can you post the URL...? (Well, if it's not behind L&P...)
I'm actually "working" on some AI Script able to solve such "Challenges"/"Puzzles" in less than 1 sec from the first Run, ah-ah...! (Without any prior Inspection of the Site / Source Code / etc...) :twisted:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
weilies
Posts: 6
Joined: Wed Aug 16, 2017 2:15 am

Re: How to get keyword from page source?

Post by weilies » Wed Aug 16, 2017 3:52 am

Okok, thanks chivracq

I know you are kind enough and just want me to learn as noobs. i have basic programming skill but not imacros. But i am willing to learn.
Next time will post more specific detail instead of jz break into Chrom-add-on sub forum :D

if you check further, it's NOT a captcha topic as initially i thought it was. The site actually use "number.png" to represent the captcha. So it's bascially a web scraping skill needed. :)

I am sorry for can't disclose the URL as we promised to keep it private. i apologize for that.

Could you refer me any relevant tutorials related to
  • 1. CONCATENATE STRING
    2. Extract Image SRC and assign to VARIABLES
    3. Make '1234' a variable instead of a hardcoded text

Code: Select all

TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:mainf ATTR=NAME:capcha CONTENT=<my variable>
I tried to search for tutorial, http://wiki.imacros.net/Data_Extraction
But it seems like it's not the add-on tool and i lost there.

Plz show me some light.

Thanks
chivracq
Posts: 8786
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to get keyword from page source?

Post by chivracq » Wed Aug 16, 2017 6:30 am

weilies wrote:Okok, thanks chivracq

I know you are kind enough and just want me to learn as noobs. i have basic programming skill but not imacros. But i am willing to learn.
Next time will post more specific detail instead of jz break into Chrom-add-on sub forum :D

if you check further, it's NOT a captcha topic as initially i thought it was. The site actually use "number.png" to represent the captcha. So it's bascially a web scraping skill needed. :)

I am sorry for can't disclose the URL as we promised to keep it private. i apologize for that.

Could you refer me any relevant tutorials related to
  • 1. CONCATENATE STRING
    2. Extract Image SRC and assign to VARIABLES
    3. Make '1234' a variable instead of a hardcoded text

Code: Select all

TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:mainf ATTR=NAME:capcha CONTENT=<my variable>
I tried to search for tutorial, http://wiki.imacros.net/Data_Extraction
But it seems like it's not the add-on tool and i lost there.

Plz show me some light.

Thanks
Yeah..., not complicated, for each Image => 'TAG' + 'EXTRACT=HREF', then mini-'EVAL()' to isolate the Data you want to keep for each Image, and a final mini-'EVAL()' Statement to reconstruct the final String...
Everything is explained on the Wiki Pages for 'TAG' + 'EVAL()'..., and you'll find dozens of Examples on the Forum...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
weilies
Posts: 6
Joined: Wed Aug 16, 2017 2:15 am

Re: How to get keyword from page source?

Post by weilies » Thu Aug 17, 2017 2:31 am

Hi, turn out the image HTML is not generated from server responses but via javascript!! what a smart way to prevent us from retrieve the content... can imacros still work??

Code: Select all

      <td><div id="img1">&nbsp;</div></td>
      <td><div id="img2">&nbsp;</div></td>
      <td><div id="img3">&nbsp;</div></td>
      <td><div id="img4">&nbsp;</div></td>
      <td><div id="img5">&nbsp;</div></td>
javascript

Code: Select all

 function getcapcha(){
  ctext="";
  html="";
  for (i=1;i<=4;i++){
   rint=getrandomint(0,ln-1);
   recsym=cstr.substr(rint,1);
   ctext=ctext+recsym;
   document.getElementById('img'+i).innerHTML="<img width='35' height='55' src='images/cap/"+recsym+".png'>";
  }
 }

call of the JS function

Code: Select all

<script>
 getcapcha();
 getadvblock();
</script>
</body>
</html>
Post Reply