-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbotScrape.py
47 lines (39 loc) · 2.01 KB
/
botScrape.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# C:\Program Files\Google\Chrome\Application\Chrome.exe
import csv
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://secure3.mbsbooks.com/employee/IndexInsite.aspx?s=order.centralstores.iastate.edu")
#Login Information
driver.find_element_by_id('txtUsername').send_keys('osborcon')
driver.find_element_by_id('txtPassword').send_keys('#')
driver.find_element_by_id('LoginButton').click()
with open('test.csv', 'w', encoding='UTF8') as f:
writer = csv.writer(f)
SKU = 2005766
while SKU < 2005809:
driver.get("https://secure3.mbsbooks.com/employee/prodAdmin.aspx?s=order.centralstores.iastate.edu")
driver.find_element_by_id('mer_sku').send_keys(SKU)
driver.find_element_by_id('btnSubmit').click()
try:
description = driver.find_element_by_id('tabContainer1_pnlBasicInfo_mer_desc_long').get_attribute('value')
except:
driver.get("https://secure3.mbsbooks.com/employee/prodAdmin.aspx?s=order.centralstores.iastate.edu")
description = 'null'
try:
driver.find_element_by_id('tabContainer1_pnlImages_Label3').click()
except:
driver.get("https://secure3.mbsbooks.com/employee/prodAdmin.aspx?s=order.centralstores.iastate.edu")
try:
thumbnail = driver.find_element_by_id('tabContainer1_pnlImages_imgDefaultThumbnail').get_attribute('src')
except:
driver.get("https://secure3.mbsbooks.com/employee/prodAdmin.aspx?s=order.centralstores.iastate.edu")
thumbnail = 'null'
try:
driver.find_element_by_id('hlAdmin').click()
except:
driver.get("https://secure3.mbsbooks.com/employee/prodAdmin.aspx?s=order.centralstores.iastate.edu")
strip = [SKU,description,thumbnail]
writer.writerow(strip)
SKU = SKU + 1