-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 #3367 from seleniumbase/cdp-mode-patch-22
CDP Mode - Patch 22
- Loading branch information
Showing
15 changed files
with
260 additions
and
506 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,11 @@ | ||
from seleniumbase import SB | ||
|
||
with SB(uc=True, test=True, locale_code="en", pls="none") as sb: | ||
sb.activate_cdp_mode("https://www.gettyimages.com/") | ||
sb.cdp.click('label:contains("Editorial")') | ||
sb.cdp.press_keys("form input", "comic con 2024 sci fi panel\n") | ||
sb.sleep(3) | ||
items = sb.cdp.find_elements("figure picture img") | ||
for item in items: | ||
item.flash(color="44CC88") | ||
sb.sleep(0.08) |
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,25 @@ | ||
from seleniumbase import SB | ||
|
||
with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: | ||
url = "https://www.kohls.com/" | ||
sb.activate_cdp_mode(url) | ||
sb.sleep(2.5) | ||
search = "Mickey Mouse 100 friends teal pillow" | ||
required_text = "Mickey" | ||
sb.cdp.press_keys('input[name="search"]', search + "\n") | ||
sb.sleep(5) | ||
for item in sb.cdp.find_elements("div.products-container-right"): | ||
if "Sponsored" in item.text: | ||
item.remove_from_dom() | ||
sb.cdp.remove_elements("#tce-sticky-wrapper") | ||
sb.cdp.remove_elements("li.sponsored-product") | ||
sb.cdp.remove_elements("#tce-dec-ces-3-banner") | ||
print('*** Kohls Search for "%s":' % search) | ||
for item in sb.cdp.find_elements("ul.products a img"): | ||
if item: | ||
item.flash(color="44CC88") | ||
title = item.get_attribute("title") | ||
if title and required_text in title: | ||
print("* " + title) | ||
sb.sleep(0.1) | ||
sb.sleep(1) |
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 @@ | ||
"""Simple web-scraping example in CDP Mode""" | ||
from seleniumbase import SB | ||
|
||
with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: | ||
url = "https://architectureofcities.com/roman-theaters" | ||
sb.activate_cdp_mode(url) | ||
sb.cdp.click_if_visible("#cn-close-notice") | ||
sb.sleep(2) | ||
print("*** " + sb.cdp.get_text("h1") + " ***") | ||
for item in sb.cdp.find_elements("h3"): | ||
if item.text and "." in item.text: | ||
item.flash(color="44CC88") | ||
sb.cdp.scroll_down(34) | ||
print("* " + item.text.replace(" ", " ")) | ||
sb.sleep(0.15) | ||
sb.sleep(1) |
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.