• „PHP“ 로고
  • „Python“ 로고
  • „Java“ 로고
  • „C#“ 로고
  • „Ruby“ 로고
  • „Golang“ 로고
  • „JavaScript“ 로고
Bypass captcha in Ruby

Bypass captcha in Ruby
„Ruby“ 로고
  • „PHP“ 로고
  • „Python“ 로고
  • „Java“ 로고
  • „C#“ 로고
  • „Ruby“ 로고
  • „Golang“ 로고
  • „JavaScript“ 로고

Ruby gem for easy integration with the API of captcha solving service to bypass reCAPTCHA, Arkose captcha, Geetest and solve any other captchas. This is the easiest way to quickly integrate 2Captcha solving service into code and automate solving of any type of captcha.

빠른 시작

설치

스크립트 패키지는 패키지 설치 관리자를 사용하거나 수동으로 설치될 수 있습니다

Bundler

To install a gem, you can use the bundler package manager. Download it from the link and install according to the instructions.

# Gemfile
gem 'ruby-2captcha'

We invite you to explore our GitHub repository where you can find ruby API client for easy integration with our API.

구성

설치된 패키지를 구성하는 데 필요한 모든 파라미터에 관한 설명

Api2Captcha 클래스의 인스턴스는 다음과 같이 생성될 수 있습니다:

client = Api2Captcha.new('YOUR_API_KEY')

또한 생성된 인스턴스에 대한 일부 옵션을 원하는 대로 바꿀 수도 있습니다:

client = Api2Captcha.new("YOUR_API_KEY")
client.api_key = "YOUR_API_KEY"
Api2Captcha 인스턴스 옵션
옵션기본 값설명
soft_id-2Captcha 소프트웨어 카탈로그에 게시된 뒤 생성된 귀하의 소프트웨어 아이디
callback-캡차 인식 결과를 수신하는 웹 서버의 URL. URL은 계정의 핑백 설정에 먼저 등록되어야 합니다.
default_timeout120reCAPTCHA를 제외한 모든 캡차 유형에 대한 폴링 시간 초과(초). 모듈이 res.php API 엔드포인트에서 응답을 얻으려고 시도하는 시간을 정의함
recaptcha_timeout600reCAPTCHA의 폴링 시간 초과(초). 모듈이 res.php API 엔드포인트에서 응답을 얻으려고 시도하는 시간을 정의함
polling_interval10res.php API 엔드포인트로의 요청 사이 간격(초), 5초 미만의 값을 설정하는 것은 권장하지 않음
중요: Api2Captcha 인스턴스에 대해 callback이 정의되면, 모든 수단이 캡차 아이디만 반환하고 결과를 얻기 위해 API를 폴링하지 않습니다. 결과는 콜백 URL로 전송됩니다. 수동으로 답변을 얻으려면 getResult 수단을 사용하십시오.

캡차 해결

이미지 기반 캡차를 제출할 때, {{site_name}의 작업자가 올바르게 캡차를 해결할 수 있도록 추가적인 옵션을 제공할 수 있습니다

캡차 옵션
옵션기본값설명
numeric0캡차에 숫자 또는 기타 기호가 포함되어 있는지 여부를 정의합니다 자세한 내용은 API 문서를 참조하십시오
min_len0답변 최소 글자수
max_len0답변 최대 글자수
phrase0답변에 여러 단어가 포함되어 있는지 여부를 정의합니다
case_sensitive0답변이 대소문자를 구분하는지 여부를 정의합니다
calc0캡차가 계산이 필요한지 정의합니다
lang-캡차 언어를 정의합니다, 지원하는 언어 목록을 참조하십시오
hint_image-캡차를 해결할 작업자에게 힌트가 표시된 이미지
hint_text-캡차를 해결할 작업자에게 표시되는 힌트 또는 작업 텍스트
simpleCaptcha

일반 캡차 (이미지 속 왜곡된 텍스트)를 우회하려면 다음의 방법을 사용합니다. 또한 해당 방법은 이미지에 있는 텍스트를 인식하는 데 사용될 수 있습니다.

result = client.normal({ image: 'path/to/captcha.jpg'})
# OR
result = client.normal({
  image: 'https://site-with-captcha.com/path/to/captcha.jpg'
})
textCaptcha

해당 방법은 일반 텍스트로 제공된 질문에 대답해야 하는 캡차를 우회하는 데 사용할 수 있습니다.

result = client.text({
  textcaptcha:'If tomorrow is Saturday, what day is today?',
  lang: "en"
})
recaptchaV2

해당 방법을 사용하면 reCAPTCHA V2를 해결하고, 토큰을 가져와 보호를 우회할 수 있습니다.

result = client.recaptcha_v2({
  googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',
  pageurl: 'https://mysite.com/page/with/recaptcha_v2'
})
recaptchaV3

해당 방법은 reCAPTCHA V3 해결사를 제공하고 토큰을 반환합니다.

result = client.recaptcha_v3({
  googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',
  pageurl: 'https://mysite.com/page/with/recaptcha_v3',
  version: 'v3',
  score: 0.3,
  action: 'verify'
})
funCaptcha

FunCaptcha (Arkoselabs) 해결 방법. 토큰 반환.

result = client.funcaptcha({
  publickey: "69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC",
  pageurl: "https://mysite.com/page/with/funcaptcha",
  surl: "https://client-api.arkoselabs.com"
})
GeeTest

GeeTest 퍼즐 캡차를 해결하는 방법. 토큰 집합을 JSON으로 반환.

KeyCaptcha

KeyCaptcha를 해결할 수 있는 토큰 기반 방법.

capy

Capy 퍼즐 캡차를 우회할 수 있는 토큰 기반 방법.

result = client.capy({
  sitekey: 'PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v',
  pageurl: 'http://mysite.com/',
  api_server: 'https://jp.api.capy.me/'
})
grid

Grid 방법은 원래 Old reCAPTCHA V2 방법이라고도 알려져 있습니다. 해당 방법은 이미지에 그리드를 적용할 수 있고, 특정 그리드 상자를 클릭해야 하는 모든 유형의 캡차를 우회하는 데 사용할 수 있습니다. 박스 수 반환.

result = client.grid({
  image: 'path/to/captcha.jpg',
  rows: 3,
  cols: 3,
  previous_id: 0,
  lang: 'en',
  hint_image: 'path/to/hint.jpg',
  hint_text: 'Select all images with an Orange'
})
canvas

캔버스 방법은 이미지 개체 주위에 선을 그어야 할 때 사용될 수 있습니다. 점의 좌표 집합을 반환하여 다각형을 그립니다.

result = client.canvas({
  image: 'path/to/captcha.jpg',
  previous_id: 0,
  lang: 'en',
  hint_image: 'path/to/hint.jpg',
  hint_text: 'Draw around apple'
})
clickCaptcha

ClickCaptcha 방법은 캡처차이미지에 있는 점의 좌표를 반환합니다. 이미지의 특정 지점을 클릭해야 하는 경우 사용할 수 있습니다.

result = client.coordinates({
  image: 'path/to/captcha.jpg',
  lang: 'en',
  hint_image: 'path/to/hint.jpg',
  hint_text: 'Connect the dots'
})
rotateCaptcha

해당 방법은 객체를 회전하도록 요청하는 캡차를 해결할 때 사용할 수 있습니다. 대부분 FunCaptcha를 우회하는 데 사용됩니다. 회전 각도 반환.

result = client.rotate({
  image: 'path/to/captcha.jpg',
  angle: 40,
  lang: 'en',
  hint_image: 'path/to/hint.jpg',
  hint_text: 'Put the images in the correct way'
})

다른 방법

기본 스크립트 작업 중에 사용되는 추가적인 유효한 방법들

send / get_result

이러한 방법들은 수동 캡차 제출 및 응답 폴링에 사용될 수 있습니다.

# example for normal captcha
captcha_id = client.send('path/to/captcha.jpg')

# or for another captcha, for example for lemin
captcha_id = client.send({
  method:"lemin",
  captcha_id: "CROPPED_3dfdd5c_d1872b526b794d83ba3b365eb15a200b",
  api_server: "api.leminnow.com",
  div_id: "lemin-cropped-captcha",
  pageurl: "https://www.site.com/page/"
})

time.sleep(20)

# Get result
result = client.get_result(captcha_id)

get_balance

해당 수단을 사용하여 계정의 잔액을 확인하십시오.

balance = client.get_balance

report

해당 방법을 사용하여 캡차의 답이 정답 또는 잘못된 답인지 보고하십시오.

client.report(captcha_id, True) # captcha solved correctly
client.report(captcha_id, False) # captcha solved incorrectly

오류 처리

요청을 처리할 때 서비스에서 반환된 표준 오류의 가능한 변형

If case of an error captcha solver throws an exception. It's important to properly handle these cases. We recommend to use begin/rescue to handle exceptions.

begin
result = client.text('If tomorrow is Saturday, what day is today?')
rescue Api2Captcha::ValidationException => e
  # invalid parameters passed
  puts(e)
rescue Api2Captcha::NetworkException => e
  # network error occurred
  puts(e)
rescue Api2Captcha::ApiException => e
  # api respond with error
  puts(e)
rescue Api2Captcha::TimeoutException => e
  # captcha is not solved so far
  puts(e)
end

서비스 API와의 통합할 수 있는 기타 언어