-
Notifications
You must be signed in to change notification settings - Fork 997
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3328 from seleniumbase/cdp-mode-patch-17
CDP Mode - Patch 17
- Loading branch information
Showing
17 changed files
with
318 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""Using CDP Mode with PyAutoGUI to bypass CAPTCHAs.""" | ||
from seleniumbase import SB | ||
|
||
with SB(uc=True, test=True, locale_code="en") as sb: | ||
url = "https://www.cloudflare.com/login" | ||
sb.activate_cdp_mode(url) | ||
sb.sleep(2) | ||
sb.uc_gui_handle_captcha() # PyAutoGUI press Tab and Spacebar | ||
sb.sleep(2) | ||
|
||
with SB(uc=True, test=True, locale_code="en") as sb: | ||
url = "https://www.cloudflare.com/login" | ||
sb.activate_cdp_mode(url) | ||
sb.sleep(2) | ||
sb.uc_gui_click_captcha() # PyAutoGUI click. (Linux needs it) | ||
sb.sleep(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from seleniumbase import SB | ||
|
||
with SB(uc=True, incognito=True, test=True) as sb: | ||
sb.activate_cdp_mode("https://pixelscan.net/") | ||
sb.sleep(3) | ||
sb.remove_elements("div.banner") # Remove the banner | ||
sb.remove_elements("jdiv") # Remove chat widgets | ||
sb.cdp.scroll_down(15) | ||
not_masking_text = "You are not masking your fingerprint" | ||
sb.assert_text(not_masking_text, "pxlscn-fingerprint-masking") | ||
no_automation_detected = "No automation framework detected" | ||
sb.assert_text(no_automation_detected, "pxlscn-bot-detection") | ||
sb.highlight("span.text-success", loops=8) | ||
sb.sleep(1) | ||
fingerprint_masking_div = "pxlscn-fingerprint-masking div" | ||
sb.highlight(fingerprint_masking_div, loops=9) | ||
sb.sleep(1) | ||
sb.highlight(".bot-detection-context", loops=10) | ||
sb.sleep(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Using CDP.network.RequestWillBeSent and CDP.network.ResponseReceived.""" | ||
import colorama | ||
import mycdp | ||
import sys | ||
from seleniumbase import SB | ||
|
||
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX | ||
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX | ||
cr = colorama.Style.RESET_ALL | ||
if "linux" in sys.platform: | ||
c1 = c2 = cr = "" | ||
|
||
|
||
async def send_handler(event: mycdp.network.RequestWillBeSent): | ||
r = event.request | ||
s = f"{r.method} {r.url}" | ||
for k, v in r.headers.items(): | ||
s += f"\n\t{k} : {v}" | ||
print(c1 + "*** ==> RequestWillBeSent <== ***" + cr) | ||
print(s) | ||
|
||
|
||
async def receive_handler(event: mycdp.network.ResponseReceived): | ||
print(c2 + "*** ==> ResponseReceived <== ***" + cr) | ||
print(event.response) | ||
|
||
|
||
with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: | ||
url = "https://www.nike.com/" | ||
sb.activate_cdp_mode(url) | ||
sb.cdp.add_handler(mycdp.network.RequestWillBeSent, send_handler) | ||
sb.cdp.add_handler(mycdp.network.ResponseReceived, receive_handler) | ||
sb.sleep(2.5) | ||
sb.cdp.gui_click_element('div[data-testid="user-tools-container"]') | ||
sb.sleep(1.5) | ||
search = "Nike Air Force 1" | ||
sb.cdp.press_keys('input[type="search"]', search) | ||
sb.sleep(4) | ||
elements = sb.cdp.select_all('ul[data-testid*="products"] figure .details') | ||
if elements: | ||
print('**** Found results for "%s": ****' % search) | ||
for element in elements: | ||
print("* " + element.text) | ||
sb.sleep(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# seleniumbase package | ||
__version__ = "4.33.6" | ||
__version__ = "4.33.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.