-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathback.py
31 lines (27 loc) · 1.02 KB
/
back.py
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
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from soup import Soupify
from createFile import showFile
from selenium.common.exceptions import NoSuchElementException
def Start(numbers):
PATH = "C:\Program Files (x86)\chromedriver.exe"
storeList = []
try:
for store in numbers:
PAGE = f"https://stores.staples.com/search?storeId={store}&qp={store}&l=en"
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--incognito')
options.add_argument('--headless')
driver = webdriver.Chrome(PATH, chrome_options=options)
driver.get(PAGE)
driver.find_element(By.CLASS_NAME, 'Teaser-titleLink').click()
source = driver.page_source
driver.quit()
Soupify(source, storeList)
except NoSuchElementException:
print(f'Store {store} doesnt exist')
driver.quit()
return
showFile()