Solve Image CAPTCHA

Premades & Resources to be used with Helium Scraper 3
Post Reply
webmaster
Site Admin
Posts: 521
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Solve Image CAPTCHA

Post by webmaster » Sun Apr 07, 2019 10:04 pm

Requires version 3.1.8.7 or later

This premade uses the Anti Captcha service to solve image CAPTCHAs, such as this:

image.jpg
image.jpg (2.74 KiB) Viewed 22959 times

You'll be required to enter 4 parameters:
  • Account Key: This is the account key the Anti Captcha service gives you when you sign up.
  • CAPTCHA Image Selector: A selector that selects the CAPTCHA image. It must be an IMG element.
  • CAPTCHA Input Selector: A selector that selects the input where you'd type the CAPTCHA solution.
  • Case Sensitive: If set to true, the worker will see a special mark telling that the answer must be entered with case sensitivity.
Once this has been imported from the Wizard, a new global will be created with all the variables already in place, so these parameters will need to be given only once, even if the global is used on many places. The global can be used at any point where a CAPTCHA may be shown, usually after a navigation. If there's no CAPTCHA to solve, the extraction will continue normally. Note that the newly created global (by default called SolveImageCAPTCHA) can be edited at any time by double clicking it to change its parameters, and these changes will affect every place in which the global is used.

It is recommended to first import it into a global, and then double click the action and select Run in Browser in a page that shows a CAPTCHA, to make sure that all parameters have been entered correctly. After running it, the browser should have navigated to the page you're trying to reach. If anything fails, you can get more information on the project's log.

It is not recommended to import it manually, but it can be done by copying the code below and pasting it into a new global, and then manually entering the 4 parameter placeholders at the bottom. Be sure to use the right data types when doing so (accountKey: string, imageSelector: selector, inputSelector: selector, caseSensitive: boolean).

Code: Select all

invoke
   function (accountKey imageSelector inputSelector caseSensitive)
      State.Down
         ·  Sequence.FirstOrDefault
               ·  imageSelector
                  Browser.EvalScript
                     ·  String.Download
                           ·  "https://www.heliumscraper.com/scripts/anti/image.js?v=6"
                     ·  struct
                           accountKey
                              accountKey
                           caseSensitive
                              caseSensitive
                  as text
                  SelectBy.Script
                     ·  "return [document.body];"
                  Sequence.Require
                     ·  inputSelector
                  Browser.InputValue
                     ·  text
                  Browser.Wait
                     ·  2000
                  Browser.PressKey
                     ·  13
   ·  [accountKey]
   ·  [imageSelector]
   ·  [inputSelector]
   ·  [caseSensitive]
Juan Soldi
The Helium Scraper Team

CharlesVuple
Posts: 2
Joined: Tue Jul 30, 2019 9:05 am
Location: United States
Contact:

Solve Image CAPTCHA

Post by CharlesVuple » Mon Sep 16, 2019 6:31 am

Hi,

I want to refresh the CAPTCHA image when the user puts wrong password. Right now when the password is wrong, it will change the image but underlying digits will be same. I want to generate completely new image with different digits for each password attempt. Is it possible to do that?

Thanks in advance,
Regards,
Sunil

webmaster
Site Admin
Posts: 521
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Re: Solve Image CAPTCHA

Post by webmaster » Tue Sep 24, 2019 5:54 pm

Are you doing anything to reload the image? The following will reload the page and try again recursively while the captcha image is still found:

Code: Select all

Sequence.Last
   ·  Sequence.Do
         ·  Select.CaptchaImage
            Browser.RunScript
               ·  "window.location.reload()"
               ·  0
            SolveImageCAPTCHA
Just replace Select.CaptchaImage with the selector that selects the captcha image, and SolveImageCAPTCHA with the name you used when imported the premade. You can store this in a separate global and use this global instead of SolveImageCAPTCHA.
Juan Soldi
The Helium Scraper Team

niltonoliveira
Posts: 4
Joined: Sun Oct 27, 2019 10:06 pm

Re: Solve Image CAPTCHA

Post by niltonoliveira » Sun Oct 27, 2019 10:54 pm

Hi,
How do I do when capcha resolution fails? not to move to the next page without data extraction.

thanks

webmaster
Site Admin
Posts: 521
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Re: Solve Image CAPTCHA

Post by webmaster » Mon Oct 28, 2019 2:22 pm

Hi,

The code above (in my response to the previous question) will keep solving the captcha until it's gone, so it should also work in this case, as long as the site shows the catpcha again when resolution fails. Is that how it works on the site you're scraping from?
Juan Soldi
The Helium Scraper Team

niltonoliveira
Posts: 4
Joined: Sun Oct 27, 2019 10:06 pm

Re: Solve Image CAPTCHA

Post by niltonoliveira » Mon Oct 28, 2019 2:42 pm

Perfect, the site I'm going to extract renews the image if you get an error. Thank you very much

Post Reply