How to skip block of code when needed

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
Jxnderson
Posts: 12
Joined: Tue Apr 11, 2023 12:05 am

How to skip block of code when needed

Post by Jxnderson » Mon May 22, 2023 2:11 pm

I need to skip a specific code block in imacros

Firstly these are my versions.
Mozilla Firefox 48.0.2
Imacros 8.9.7

I have a script that automates a task. She first goes to the specific site, does what she should do and then opens the captcha site, runs the anticaptcha system, then returns to the first site, puts the captcha obtained and clicks on the final button...
However, there are times when the use of captcha is not necessary. Eu tenho um script que automatiza uma tarefa. Ela primeiro vai no site específico, faz o que deve fazer e depois abre o site captcha, roda o sistema anticaptcha, depois volta pro primeiro site, coloca o captcha obtido e clica no botão final...
No entanto, há momentos em que o uso do captcha não é necessário. isso acontece aleatoriamente. Queria saber se é possível fazer o imacros entender quando não será necessário ele fazer todo o processo para contornar o captcha e pular para o último botão.

this is my complete code:

Code: Select all

VERSION BUILD=8970419 RECORDER=FX
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 5
SET !ERRORIGNORE YES

SET !DATASOURCE C:\iMacros\Datasources\namePC.csv
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !VAR1 {{!COL1}}

URL GOTO=http://www.narutoplayers.com.br/np2/?p=cacadas
TAG POS=2 TYPE=SELECT ATTR=ID:server CONTENT=%1
TAG POS=1 TYPE=SELECT ATTR=ID:por_nivel CONTENT=%1
TAG POS=2 TYPE=INPUT:SUBMIT ATTR=ID:confirmar
WAIT SECONDS=1

SET !EXTRACT_TEST_POPUP NO
TAB T=1
TAB CLOSEALLOTHERS

SET API myAPI

FILEDELETE NAME=C:\Captcha\nP.png
ONDOWNLOAD FOLDER=C:\Captcha FILE=nP.png
TAG POS=1 TYPE=IMG ATTR=ID:img_captcha CONTENT=EVENT:SAVE_ELEMENT_SCREENSHOT

TAB OPEN
TAB T=2
URL GOTO=https://2captcha.com/imacros.html
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:http://rucaptcha.com/in.php ATTR=NAME:key CONTENT=myAPI
TAG POS=1 TYPE=INPUT:FILE FORM=ACTION:http://rucaptcha.com/in.php ATTR=NAME:file CONTENT=C:\Captcha\nP.png
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:http://rucaptcha.com/in.php ATTR=NAME:regsense CONTENT=1 
ONDIALOG POS=1 BUTTON=OK CONTENT=
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:http://rucaptcha.com/in.php ATTR=*
WAIT SECONDS=10
TAG POS=1 TYPE=* ATTR=TXT:* EXTRACT=TXT
SET ID EVAL("var s='{{!EXTRACT}}'; var z=s.split('|')[1]; z;")
URL GOTO=http://rucaptcha.com/res.php?key={{API}}&action=get&id={{ID}}
SET !EXTRACT NULL
TAG POS=1 TYPE=* ATTR=TXT:* EXTRACT=TXT
SET CAPTCHA EVAL("var s='{{!EXTRACT}}'; var z=s.split('|')[1]; z;")
WAIT SECONDS=1
TAB CLOSE

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:form1 ATTR=ID:codigo CONTENT={{CAPTCHA}}
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=ID:confirmar
WAIT SECONDS=300

the task without the captcha process would look like +/- like this

Code: Select all

URL GOTO=http://www.narutoplayers.com.br/np2/?p=cacadas
TAG POS=2 TYPE=SELECT ATTR=ID:server CONTENT=%1
TAG POS=1 TYPE=SELECT ATTR=ID:por_nivel CONTENT=%1
TAG POS=2 TYPE=INPUT:SUBMIT ATTR=ID:confirmar
WAIT SECONDS=1

TAG POS=1 TYPE=INPUT:SUBMIT ATTR=ID:confirmar

I would need it to ignore this code block. it's possible?

Code: Select all

TAB OPEN
TAB T=2
URL GOTO=https://2captcha.com/imacros.html
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:http://rucaptcha.com/in.php ATTR=NAME:key CONTENT=myAPI
TAG POS=1 TYPE=INPUT:FILE FORM=ACTION:http://rucaptcha.com/in.php ATTR=NAME:file CONTENT=C:\Captcha\nP.png
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:http://rucaptcha.com/in.php ATTR=NAME:regsense CONTENT=1 
ONDIALOG POS=1 BUTTON=OK CONTENT=
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:http://rucaptcha.com/in.php ATTR=*
WAIT SECONDS=10
TAG POS=1 TYPE=* ATTR=TXT:* EXTRACT=TXT
SET ID EVAL("var s='{{!EXTRACT}}'; var z=s.split('|')[1]; z;")
URL GOTO=http://rucaptcha.com/res.php?key={{API}}&action=get&id={{ID}}
SET !EXTRACT NULL
TAG POS=1 TYPE=* ATTR=TXT:* EXTRACT=TXT
SET CAPTCHA EVAL("var s='{{!EXTRACT}}'; var z=s.split('|')[1]; z;")
WAIT SECONDS=1
TAB CLOSE

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:form1 ATTR=ID:codigo CONTENT={{CAPTCHA}}
thank you in advance.
Post Reply