platonai / PulsarRPA

Automate webpages at scale, scrape web data completely and accurately with high performance, distributed AI-RPA.
Apache License 2.0
766 stars 118 forks source link

Can I install browser plugins like 2Captcha to solve captchas? #73

Open willowypanda opened 3 months ago

willowypanda commented 3 months ago

If so, how can I do it in PulsarRPA? Thanks!

platonai commented 3 months ago

Sure! You can add an event handler to check and resolve captchas:

Here is a simple demo:

    fun options(args: String): LoadOptions {
        val options = session.options(args)

        val be = options.event.browseEventHandlers

        be.onDocumentActuallyReady.addLast { page, driver ->
            // Check if the page shows captchas here
            // If the captcha appears, call 2Captcha
        }

        return options
    }

    val url = "https://www.amazon.com/dp/B0C1H26C46"
    val args = "-refresh"
    session.load(url, options(args))

source code: https://github.com/platonai/PulsarRPA/blob/4900e8911c6d500cd3bf8d4512e7c3a689894caf/pulsar-app/pulsar-examples/src/main/kotlin/ai/platon/pulsar/examples/_7_RPA.kt

For all available event handlers, see:

https://github.com/platonai/PulsarRPA/blob/4900e8911c6d500cd3bf8d4512e7c3a689894caf/pulsar-app/pulsar-examples/src/main/kotlin/ai/platon/pulsar/examples/_6_EventHandler.kt