OCR Screen Scrapping

Hi There,
I would like to scrap a security stamp calculation from this site (https://itax.kra.go.ke/KRA-Portal/pinChecker.htm?actionCode=loadPage&viewType=static). I’m able to scrap but my issue is how do I perform the calculation after that. Considering the output is string and the sum/subtract sign changes. I’m fairly new to uipath. Any help will be appreciated.

Hi @Jonathan_Mbiriri ,

If the Captcha only uses the Basic Arithmetic Operations between two Numbers we could make use of Regular Expressions to retrieve the Two Numbers from the Text and use a Switch Case on 4 Arithmetic Operations to perform the operation between 2 numbers.

Let’s take the Below Captcha :

Extracted String would be the Below after OCR :

92 +2?

Now to Extract the Two Numbers and the Operator using Regex:

FirstOperand = System.Text.RegularExpressions.Regex.Match(captchaText,"(\d+)\s*(.)\s*(\d+)\s*\?").Groups(1).Value.ToString.Trim

SecondOperand = System.Text.RegularExpressions.Regex.Match(captchaText,"(\d+)\s*(.)\s*(\d+)\s*\?").Groups(3).Value.ToString.Trim

op = System.Text.RegularExpressions.Regex.Match(captchaText,"(\d+)\s*(.)\s*(\d+)\s*\?").Groups(2).Value.ToString.Trim

Note that the above Expressions should be used with an Assign Activity.
Where FirstOperand, SecondOperand and Op are String variables and captchaText be the output from the OCR.

Now, we could use the Switch Activity to Perform the Operation as desired in the below way :


Let us know if you are need of further help.

@fernando_zuluaga the symbol(add/subtract) changes as you refresh it

@supermanPunch, please share the workflow.

Hi @Jonathan_Mbiriri ,

May we ask what OCR have you used to for Retrieval Of the Text in Captcha ?

@supermanPunch Microsoft OCR

@Jonathan_Mbiriri ,

Check the Below Workflow :
Captcha_ArithmeticOperations.xaml (9.2 KB)

Let us know if it is not working as expected.

@supermanPunch works. Thanks alot

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.