File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed
examples/cdp_mode/playwright Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change 1+ from playwright .sync_api import sync_playwright
2+ from seleniumbase import sb_cdp
3+
4+ sb = sb_cdp .Chrome (locale = "en" )
5+ endpoint_url = sb .get_endpoint_url ()
6+
7+ with sync_playwright () as p :
8+ browser = p .chromium .connect_over_cdp (endpoint_url )
9+ context = browser .contexts [0 ]
10+ page = context .pages [0 ]
11+ page .goto ("https://www.cloudflare.com/login" )
12+ sb .sleep (3 )
13+ sb .solve_captcha ()
14+ sb .sleep (3 )
Original file line number Diff line number Diff line change 1+ from playwright .sync_api import sync_playwright
2+ from seleniumbase import sb_cdp
3+
4+ sb = sb_cdp .Chrome ()
5+ endpoint_url = sb .get_endpoint_url ()
6+
7+ with sync_playwright () as p :
8+ browser = p .chromium .connect_over_cdp (endpoint_url )
9+ context = browser .contexts [0 ]
10+ page = context .pages [0 ]
11+ page .goto ("https://www.nike.com/" )
12+ page .click ('[data-testid="user-tools-container"] search' )
13+ search = "Pegasus"
14+ page .fill ('input[type="search"]' , search )
15+ sb .sleep (4 )
16+ details = 'ul[data-testid*="products"] figure .details'
17+ items = page .locator (details )
18+ if items :
19+ print ('**** Found results for "%s": ****' % search )
20+ for i in range (items .count ()):
21+ item = items .nth (i )
22+ print (item .inner_text ())
Original file line number Diff line number Diff line change 1+ from playwright .sync_api import sync_playwright
2+ from seleniumbase import sb_cdp
3+
4+ sb = sb_cdp .Chrome (locale = "en" )
5+ endpoint_url = sb .get_endpoint_url ()
6+
7+ with sync_playwright () as p :
8+ browser = p .chromium .connect_over_cdp (endpoint_url )
9+ context = browser .contexts [0 ]
10+ page = context .pages [0 ]
11+ page .goto ("https://www.nordstrom.com/" )
12+ sb .sleep (2 )
13+ page .click ("input#keyword-search-input" )
14+ sb .sleep (0.8 )
15+ search = "cocktail dresses for women teal"
16+ sb .press_keys ("input#keyword-search-input" , search + "\n " )
17+ sb .sleep (2.2 )
18+ for i in range (17 ):
19+ sb .scroll_down (16 )
20+ sb .sleep (0.14 )
21+ print ('*** Nordstrom Search for "%s":' % search )
22+ unique_item_text = []
23+ items = sb .find_elements ("article" )
24+ for item in items :
25+ description = item .querySelector ("article h3" )
26+ if description and description .text not in unique_item_text :
27+ unique_item_text .append (description .text )
28+ price_text = ""
29+ price = item .querySelector ('div div span[aria-hidden="true"]' )
30+ if price :
31+ price_text = price .text
32+ print ("* %s (%s)" % (description .text , price_text ))
You can’t perform that action at this time.
0 commit comments