valdur2000
Знающий
- Сообщения
- 155
- Репутация
- 7
Здравствуйте, для распознавания капчи использую DeathByCaptcha. В ней есть timeout, на случай если нету ответа, но вот как использовать этот таймаут незнаю. Ставлю например 60 сек, но если сервер не отвечает, то просто ничего не происходит и все. А может я не понимаю, где этот таймаут отловить. Задача: через 60 секунд получить контроль над ситуацией и заново отправить капчу на распознание. Спасибо за помощь. Внизу полный код функции из UDF.
Код:
; Decodes a CAPTCHA by uploading it and polling for its status repeatedly.
; Call with your DeathByCaptcha username/password, CAPTCHA file name and
; solving timeout (in seconds). Returns an two-elements array with CAPTCHA
; unique ID (zero if not solved) and text (empty string if not solved).
; Removes unsolved CAPTCHAs automatically.
Func DeathByCaptchaDecode($username, $password, $captchaFileName, $timeout)
Local $result[2] = [0, ""]
$result[0] = DeathByCaptchaUpload($username, $password, $captchaFileName)
If 0 < $result[0] Then
Local $deadline = $timeout * 1000
While 0 = StringLen($result[1]) AND 0 < $deadline
Sleep(10000)
$deadline -= 10000
$result[1] = DeathByCaptchaGetText($result[0])
WEnd
If 0 = StringLen($result[1]) Then
$result[0] = 0
EndIf
EndIf
Return $result
EndFunc
; Usage example
; =============
;
; Call DeathByCaptchaDecode() function with your DBC username, password,
; CAPTCHA file name, and desired solving timeout (in seconds) as arguments.
; You'll receive an array of two elements: numeric CAPTCHA ID and its text;
; CAPTCHA ID will be greater than zero if the CAPTCHA was solved.
;
;$result = DeathByCaptchaDecode($CmdLine[1], $CmdLine[2], $CmdLine[3], 60)
;MsgBox(0, "decode()", StringFormat('ID: %s, text: %s', $result[0], $result[1]))