-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathraw_nike_sync.py
More file actions
22 lines (20 loc) · 737 Bytes
/
raw_nike_sync.py
File metadata and controls
22 lines (20 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from playwright.sync_api import sync_playwright
from seleniumbase import sb_cdp
sb = sb_cdp.Chrome()
endpoint_url = sb.get_endpoint_url()
with sync_playwright() as p:
browser = p.chromium.connect_over_cdp(endpoint_url)
context = browser.contexts[0]
page = context.pages[0]
page.goto("https://www.nike.com/")
page.click('[data-testid="user-tools-container"] search')
search = "Pegasus"
page.fill('input[type="search"]', search)
sb.sleep(4)
details = 'ul[data-testid*="products"] figure .details'
items = page.locator(details)
if items:
print('**** Found results for "%s": ****' % search)
for i in range(items.count()):
item = items.nth(i)
print(item.inner_text())