• โลโก้ „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 ควรลงทะเบียนครั้งแรกใน การตั้งค่า pingback ของบัญชีของคุณ
default_timeout120หมดเวลาโพลเป็นวินาทีสำหรับแคปต์ชาทุกประเภท ยกเว้น reCAPTCHA กำหนดระยะเวลาที่โมดูลพยายามรับคำตอบจาก res.php ปลายทาง API
recaptcha_timeout600หมดเวลาโพลสำหรับ reCAPTCHA ในไม่กี่วินาที กำหนดระยะเวลาที่โมดูลพยายามรับคำตอบจาก res.php ปลายทาง API
polling_interval10ช่วงเวลาเป็นวินาทีระหว่างคำขอถึง res.php ปลายทาง API ไม่แนะนำให้ตั้งค่าน้อยกว่า 5 วินาที
สำคัญ: เมื่อcallback ถูกกำหนดไว้สำหรับ Api2Captcha ตัวอย่างเช่น วิธีทั้งหมดจะคืนค่าเฉพาะ captcha ID และอย่าสำรวจ API เพื่อรับผลลัพธ์ ผลลัพธ์จะถูกส่งไปยัง callback URL เพื่อรับคำตอบด้วยตนเอง ใช้ วิธีรับผลลัพธ์

แก้ไขแคปต์ช่า

เมื่อคุณกดการใช้แคปต์ช่าแบบรูปภาพจะมีตัวเลือกเพิ่มเติมเพื่อช่วย 2Captcha พนักงานแก้ไขให้ถูกต้อง

ตัวเลือกแคปต์ช่า
ตัวเลือกค่าเริ่มต้นคำอธิบาย
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'
})
แคปต์ช่าข้อความ

วิธีนี้สามารถใช้เพื่อหลีกเลี่ยงแคปต์ชาที่ต้องตอบคำถามที่ระบุเป็นข้อความที่ชัดเจน

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 puzzle Captcha โดยส่งกลับชุดของโทเค็นเป็น JSON

result = client.geetest({
  gt: 'f1ab2cdefa3456789012345b6c78d90e',
  api_server: 'api-na.geetest.com',
  challenge: '12345678abc90123d45678ef90123a456b',
  pageurl: 'https://www.site.com/page/'
})
keyChptcha

วิธีการที่ใช้โทเค็นเพื่อแก้ปัญหา KeyCaptcha

capy

วิธีที่ใช้โทเค็นเพื่อเลี่ยงผ่านแคปต์ชา Capy puzzle

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

คุณสามารถใช้วิธี 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'
})
หมุนแคปต์ช่า

วิธีนี้สามารถใช้แก้แคปต์ชาที่ขอให้หมุนวัตถุได้ ส่วนใหญ่ใช้เพื่อเลี่ยงผ่าน FunCaptcha ส่งกลับมุมการหมุน

วิธีอื่นๆ

วิธีการที่ถูกต้องเพิ่มเติมที่ใช้ในระหว่างการทำงานของสคริปต์หลัก

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