ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.61k stars 1.14k forks source link

Pull Request For NoDriver #1974

Open Connor9994 opened 1 month ago

Connor9994 commented 1 month ago

Still unable to file Issues and/or Pull requests for NoDriver

The non-random pauses on both of these functions get flagged on several websites as bot activity. These fixes to prevent these from being detected:

from random import *

Random delay + random location between the element's (left,top) and (right,bottom) uc.Element.mouse_move

async def mouse_move_random(self, tab):
        """moves mouse (not click), to element position. when an element has an
        hover/mouseover effect, this would trigger it
        random location between the element's (left,top) and (right,bottom)"""
        self._remote_object = await self._tab.send(cdp.dom.resolve_node(backend_node_id=self.backend_node_id))
        quads = await self.tab.send(cdp.dom.get_content_quads(object_id=self.remote_object.object_id))
        left = quads[0][0]
        top = quads[0][1]
        right = quads[0][2]
        top = quads[0][3]
        right = quads[0][4]
        bottom = quads[0][5]
        left = quads[0][6]
        bottom = quads[0][7]
        x = uniform(left, right)
        y = uniform(top, bottom)
        await self._tab.send(cdp.input_.dispatch_mouse_event("mouseMoved", x=x, y=y))
        await tab.sleep(uniform(0.15,0.35))
        await self._tab.send(cdp.input_.dispatch_mouse_event("mouseReleased", x=x, y=y))

Random delay after each character uc.Element.send_keys

async def send_keys_random(self, text: str, tab):
    """
    Send text to an input field, or any other HTML element with a random delay between each key.

    hint, if you ever get stuck where using py:meth:`~click`
    does not work, sending the keystroke \\n or \\r\\n or a spacebar work wonders!

    :param text: text to send
    :param delay: delay in seconds between keys
    :return: None
    """
    await self.apply("(elem) => elem.focus()")

    for char in list(text):
        await self._tab.send(cdp.input_.dispatch_key_event("char", text=char))
        await tab.sleep(random())

As for issues, NoDriver still is completely unable to load any Chrome components in chrome://components Please open up NoDriver for collaborations @ultrafunkamsterdam

350764697-5f7aac7d-225c-4d54-8065-9b790664f70d

nathankurtyka commented 1 month ago

@Connor9994 Instead of forking, you could consider providing a utility lib for nodriver.

There are probably a ton of other handy methods that could exist in something like that.