Giter Club home page Giter Club logo

puppeteer-captcha-solving-tutorial's Introduction

omkar

โœจ Solve Captcha in Puppeteer using CapSolver โœจ

(Programming Language - Python 3)

puppeter-captcha-solving-tutorial forks Repo stars puppeter-captcha-solving-tutorial License issues

View


๐ŸŒŸ Learn How to Solve Captchas in Puppeteer Using CapSolver ๐Ÿค–

๐ŸŽฏ Overview

This is the final code for the tutorial, which demonstrates how to solve captchas in Puppeteer using CapSolver.

By following this tutorial, you will gain the knowledge to effectively solve captchas, along with best practices to increase the chances of successful captcha solving, such as maintaining consistent user agents and IP addresses.

In the tutorial, we will be solving captchas at recaptcha-demo.appspot.com using CapSolver.

Captcha Form

The tutorial is available as a YouTube video ๐ŸŽฅ, which you can access using the following video:

Puppeteer Captcha Solving Tutorial

๐Ÿš€ Running the Code

If you are interested in seeing the captcha-solving process in action, follow these steps:

1๏ธโƒฃ Clone the repository ๐Ÿง™โ€โ™€๏ธ:

git clone https://github.com/omkarcloud/puppeter-captcha-solving-tutorial
cd puppeter-captcha-solving-tutorial

2๏ธโƒฃ Install Dependencies ๐Ÿ“ฆ:

python -m pip install pyppeteer capsolver-python

3๏ธโƒฃ Get your CapSolver API Key by following the "Setup CapSolver" section of this tutorial. Watch that section in this timestamp.

Store API Key

4๏ธโƒฃ In main.py, replace YOUR_API_KEY with your CapSolver API Key. ๐Ÿ—๏ธ

5๏ธโƒฃ Run the code to solve the captcha. ๐Ÿƒโ€โ™€๏ธ

python main.py

Once the captcha is successfully solved, you will be greeted with the following success screen ๐Ÿ˜Ž.

Solved Captcha Success Page

โœ… Final Code

Just want to see the code? Here it is, read and understand the code to grasp the process of captcha solving.:

import asyncio
from pyppeteer import launch
from capsolver_python import RecaptchaV2Task

# Following code solves a reCAPTCHA v2 challenge using CapSolver.
async def main():
    # Launch Browser.
    browser = await launch({'headless': False})

    # Load the target page.
    captcha_page_url = "https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php"
    page = await browser.newPage()
    await page.goto(captcha_page_url)

    # Solve the reCAPTCHA using CapSolver.
    print("Solving captcha")
    capsolver = RecaptchaV2Task("YOUR_API_KEY")

    site_key = "6LfW6wATAAAAAHLqO2pb8bDBahxlMxNdo9g947u9"
    task_id = capsolver.create_task(captcha_page_url, site_key)
    result = capsolver.join_task_result(task_id)

    # Get the solved reCAPTCHA code.
    code = result.get("gRecaptchaResponse")
    print(f"Successfully solved the reCAPTCHA. The solve code is {code}")

    # Set the solved reCAPTCHA code on the form.
    recaptcha_response_element = await page.querySelector('#g-recaptcha-response')
    await page.evaluate(f'(element) => element.value = "{code}"', recaptcha_response_element)

    # Submit the form.
    submit_btn = await page.querySelector('button[type="submit"]')
    await submit_btn.click()

    # Pause the execution so you can see the screen after submission before closing the driver
    input("Captcha Submission Successfull. Press enter to continue")

    # Close Browser.
    await browser.close()

if __name__ == "__main__":
    asyncio.get_event_loop().run_until_complete(main())

Want to understand the code? Watch the tutorial!

Puppeteer Captcha Solving Tutorial


Love It? Star It! โญ

Star History Chart

puppeteer-captcha-solving-tutorial's People

Contributors

chetan11-dev avatar chetanjainsirsa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

5l1v3r1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.