-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathraw_albertsons.py
More file actions
34 lines (33 loc) · 1.25 KB
/
Copy pathraw_albertsons.py
File metadata and controls
34 lines (33 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from seleniumbase import SB
with SB(uc=True, test=True, locale="en") as sb:
sb.activate_cdp_mode()
sb.goto("https://www.albertsons.com/recipes/")
sb.sleep(2.5)
sb.remove_element("div > div > article")
sb.scroll_into_view('input[type="search"]')
close_btn = ".notification-alert-wrapper__close-button"
sb.click_if_visible(close_btn)
sb.click("input#search-suggestion-input")
sb.sleep(0.2)
search = "Avocado Smoked Salmon"
required_text = "Salmon"
sb.press_keys("input#search-suggestion-input", search)
sb.sleep(0.8)
sb.click("#suggestion-0 a span")
sb.sleep(0.8)
sb.click_if_visible(close_btn)
sb.sleep(3.2)
print('*** Albertsons Search for "%s":' % search)
print(' (Results must contain "%s".)' % required_text)
unique_item_text = []
item_selector = 'a[href*="/meal-plans-recipes/shop/"]'
items = sb.find_elements(item_selector)
for item in items:
sb.sleep(0.06)
if required_text in item.text:
item.flash(color="44CC88")
sb.sleep(0.025)
if item.text not in unique_item_text:
unique_item_text.append(item.text)
print("* " + item.text)
sb.save_screenshot_to_logs()