Skip to content

Trying use requests on Selenium base #3767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Apogavi opened this issue May 23, 2025 · 8 comments
Closed

Trying use requests on Selenium base #3767

Apogavi opened this issue May 23, 2025 · 8 comments
Labels
question Someone is looking for answers UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode

Comments

@Apogavi
Copy link

Apogavi commented May 23, 2025

Hey, can I use driver.add_cdp_listener with SB?

with SB(maximize=True, uc_cdp=True) as sb:
            
            sb.driver.add_cdp_listener("Network.requestWillBeSent", self.append_request)
            sb.open(url)
            # Code continues
@mdmintz mdmintz added question Someone is looking for answers UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode labels May 23, 2025
@mdmintz
Copy link
Member

mdmintz commented May 23, 2025

There's an example of using add_cdp_listener here:

@mdmintz mdmintz closed this as completed May 23, 2025
@Apogavi
Copy link
Author

Apogavi commented May 23, 2025

@mdmintz I saw this example, but it's using BaseCase... It'll work with SB?

@mdmintz
Copy link
Member

mdmintz commented May 23, 2025

@mdmintz
Copy link
Member

mdmintz commented May 23, 2025

Also try this:

from seleniumbase import SB
from rich.pretty import pprint

def click_turnstile_and_verify(sb):
    sb.uc_gui_handle_captcha()
    sb.assert_element("img#captcha-success", timeout=3)
    sb.highlight("img#captcha-success", loops=8)

with SB(uc_cdp_events=True) as sb:
    url = "seleniumbase.io/apps/turnstile"
    sb.uc_open_with_reconnect(url, 2)
    sb.driver.add_cdp_listener(
        "Network.requestWillBeSentExtraInfo",
        lambda data: pprint(data)
    )
    click_turnstile_and_verify(sb)
    sb.sleep(1)
    sb.refresh()
    sb.sleep(1)

@mdmintz
Copy link
Member

mdmintz commented May 23, 2025

Here's the example for it:

@Apogavi
Copy link
Author

Apogavi commented May 23, 2025

I'll try all these alternatives... So far none of them have worked. I have the code in selenium, if I send the code, can you help me to convert the code?

@mdmintz
Copy link
Member

mdmintz commented May 23, 2025

@Apogavi
Copy link
Author

Apogavi commented May 23, 2025

the request that I need to capture for a list is not working, I will keep trying, if I don't succeed on Monday I will come back here! Thank you very much for your support! And yes, I tried the alternatives, I will try again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Someone is looking for answers UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode
Projects
None yet
Development

No branches or pull requests

2 participants