Web scrape Appointment Workbook to a text file
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
0
down vote
favorite
This is a Web scraping script I wrote to get data from my companies Appointment workbook into a text file so I can review each appointment that is made online through our website. The context is that I use the data in the text file to look up each appointment to get the car VIN and reschedule the appointment under my name. It saves me a lot of time using a script to get the data I need to get the Vin number of each car in every appointment.
Does this follow the common practices of Python scripts? Are nested loops common practice when making a script? The script also can be used for the Acura workbook with a change of one line, which I did to make a second Acura Script.
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
import time
def login():
#open text file to write
f = open('Honda_Appt_lists.text', 'w')
#find chrome Driver
browser = webdriver.Chrome('C:\Users\Eddie\Desktop\Script\chromedriver.exe')
#open browser to site
browser.get('https://login.xtime.com/')
#sleep to load full site
#Maximize window
browser.maximize_window()
time.sleep(5)
#Switch to the Iframe I need
browser.switch_to.frame('login')
#input login info and submit
browser.find_element_by_id('login').send_keys('username')
browser.find_element_by_id('password').send_keys('password')
browser.find_element_by_class_name('basic-button').click()
#sleep
time.sleep(5)
#Launch Honda
index = 0
while True:
honda = browser.find_elements_by_class_name('launch-button')
try:
index = index + 1
honda[index].click()
except IndexError:
break
time.sleep(10)
#Goes to workbook
#Applies Filters
browser.find_element_by_xpath('//*[@id="xt_common_header_button-1042"]').click()
time.sleep(10)
element = browser.find_element_by_id('button-1239-btnIconEl')
browser.execute_script("arguments[0].click();", element)
web_element = browser.find_element_by_xpath('//*[@id="treeview-1206-record-ext-record-163"]/td/div/span')
browser.execute_script("arguments[0].click();", web_element)
browser.find_element_by_xpath('//*[@id="button-1233-btnIconEl"]').click()
time.sleep(10)
#Sort by status
browser.find_element_by_xpath('//*[@id="button-1257-btnIconEl"]').click()
browser.implicitly_wait(5)
def calender_changer(x):
while x < 31 and x > 15:
#Find calender
div = browser.find_element_by_id('ledgerdateslider-1247-innerCt')
#hit calender
div.find_element_by_xpath('//*[@id="component-1250"]/div/table/tbody/tr/td[1]').click()
#hit calender date
browser.implicitly_wait(5)
browser.find_element_by_link_text(str(x)).click()
time.sleep(10)
try:
index = 0
while True:
header = browser.find_elements_by_class_name('x-ledgerdataview-header')
try:
time.sleep(5)
header[index].click()
while True:
name = browser.find_elements_by_class_name('x-lightcard-customer-name')
car = browser.find_elements_by_class_name('x-lightcard-vehicle-inf')
apt_time = browser.find_elements_by_class_name('x-lightcard-header-right')
contact = browser.find_elements_by_class_name('x-lightcard-contact')
note = browser.find_elements_by_class_name('x-lightcard-services')
try:
# print and write to file name/car/apt_time/contact/note
print(name[index].text)
f.write("n" + 'Name: ' + name[index].text + "n")
print(car[index].text)
f.write('Car: ' + car[index].text + "n")
print(apt_time[index].text)
f.write('Time: ' + apt_time[index].text + "n")
print(contact[index].text)
f.write('Contact: ' + contact[index].text + "n")
print(note[index].text)
f.write('Service Notes:' + note[index].text + "n")
print(x)
f.write('Date:' + x + "n")
break
except IndexError:
break
except IndexError:
x = x - 1
break
except NoSuchElementException:
x = x -1
print(x)
calender_changer(30)
time.sleep(5)
f.close()
login()
python beginner python-3.x web-scraping selenium
add a comment |Â
up vote
0
down vote
favorite
This is a Web scraping script I wrote to get data from my companies Appointment workbook into a text file so I can review each appointment that is made online through our website. The context is that I use the data in the text file to look up each appointment to get the car VIN and reschedule the appointment under my name. It saves me a lot of time using a script to get the data I need to get the Vin number of each car in every appointment.
Does this follow the common practices of Python scripts? Are nested loops common practice when making a script? The script also can be used for the Acura workbook with a change of one line, which I did to make a second Acura Script.
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
import time
def login():
#open text file to write
f = open('Honda_Appt_lists.text', 'w')
#find chrome Driver
browser = webdriver.Chrome('C:\Users\Eddie\Desktop\Script\chromedriver.exe')
#open browser to site
browser.get('https://login.xtime.com/')
#sleep to load full site
#Maximize window
browser.maximize_window()
time.sleep(5)
#Switch to the Iframe I need
browser.switch_to.frame('login')
#input login info and submit
browser.find_element_by_id('login').send_keys('username')
browser.find_element_by_id('password').send_keys('password')
browser.find_element_by_class_name('basic-button').click()
#sleep
time.sleep(5)
#Launch Honda
index = 0
while True:
honda = browser.find_elements_by_class_name('launch-button')
try:
index = index + 1
honda[index].click()
except IndexError:
break
time.sleep(10)
#Goes to workbook
#Applies Filters
browser.find_element_by_xpath('//*[@id="xt_common_header_button-1042"]').click()
time.sleep(10)
element = browser.find_element_by_id('button-1239-btnIconEl')
browser.execute_script("arguments[0].click();", element)
web_element = browser.find_element_by_xpath('//*[@id="treeview-1206-record-ext-record-163"]/td/div/span')
browser.execute_script("arguments[0].click();", web_element)
browser.find_element_by_xpath('//*[@id="button-1233-btnIconEl"]').click()
time.sleep(10)
#Sort by status
browser.find_element_by_xpath('//*[@id="button-1257-btnIconEl"]').click()
browser.implicitly_wait(5)
def calender_changer(x):
while x < 31 and x > 15:
#Find calender
div = browser.find_element_by_id('ledgerdateslider-1247-innerCt')
#hit calender
div.find_element_by_xpath('//*[@id="component-1250"]/div/table/tbody/tr/td[1]').click()
#hit calender date
browser.implicitly_wait(5)
browser.find_element_by_link_text(str(x)).click()
time.sleep(10)
try:
index = 0
while True:
header = browser.find_elements_by_class_name('x-ledgerdataview-header')
try:
time.sleep(5)
header[index].click()
while True:
name = browser.find_elements_by_class_name('x-lightcard-customer-name')
car = browser.find_elements_by_class_name('x-lightcard-vehicle-inf')
apt_time = browser.find_elements_by_class_name('x-lightcard-header-right')
contact = browser.find_elements_by_class_name('x-lightcard-contact')
note = browser.find_elements_by_class_name('x-lightcard-services')
try:
# print and write to file name/car/apt_time/contact/note
print(name[index].text)
f.write("n" + 'Name: ' + name[index].text + "n")
print(car[index].text)
f.write('Car: ' + car[index].text + "n")
print(apt_time[index].text)
f.write('Time: ' + apt_time[index].text + "n")
print(contact[index].text)
f.write('Contact: ' + contact[index].text + "n")
print(note[index].text)
f.write('Service Notes:' + note[index].text + "n")
print(x)
f.write('Date:' + x + "n")
break
except IndexError:
break
except IndexError:
x = x - 1
break
except NoSuchElementException:
x = x -1
print(x)
calender_changer(30)
time.sleep(5)
f.close()
login()
python beginner python-3.x web-scraping selenium
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This is a Web scraping script I wrote to get data from my companies Appointment workbook into a text file so I can review each appointment that is made online through our website. The context is that I use the data in the text file to look up each appointment to get the car VIN and reschedule the appointment under my name. It saves me a lot of time using a script to get the data I need to get the Vin number of each car in every appointment.
Does this follow the common practices of Python scripts? Are nested loops common practice when making a script? The script also can be used for the Acura workbook with a change of one line, which I did to make a second Acura Script.
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
import time
def login():
#open text file to write
f = open('Honda_Appt_lists.text', 'w')
#find chrome Driver
browser = webdriver.Chrome('C:\Users\Eddie\Desktop\Script\chromedriver.exe')
#open browser to site
browser.get('https://login.xtime.com/')
#sleep to load full site
#Maximize window
browser.maximize_window()
time.sleep(5)
#Switch to the Iframe I need
browser.switch_to.frame('login')
#input login info and submit
browser.find_element_by_id('login').send_keys('username')
browser.find_element_by_id('password').send_keys('password')
browser.find_element_by_class_name('basic-button').click()
#sleep
time.sleep(5)
#Launch Honda
index = 0
while True:
honda = browser.find_elements_by_class_name('launch-button')
try:
index = index + 1
honda[index].click()
except IndexError:
break
time.sleep(10)
#Goes to workbook
#Applies Filters
browser.find_element_by_xpath('//*[@id="xt_common_header_button-1042"]').click()
time.sleep(10)
element = browser.find_element_by_id('button-1239-btnIconEl')
browser.execute_script("arguments[0].click();", element)
web_element = browser.find_element_by_xpath('//*[@id="treeview-1206-record-ext-record-163"]/td/div/span')
browser.execute_script("arguments[0].click();", web_element)
browser.find_element_by_xpath('//*[@id="button-1233-btnIconEl"]').click()
time.sleep(10)
#Sort by status
browser.find_element_by_xpath('//*[@id="button-1257-btnIconEl"]').click()
browser.implicitly_wait(5)
def calender_changer(x):
while x < 31 and x > 15:
#Find calender
div = browser.find_element_by_id('ledgerdateslider-1247-innerCt')
#hit calender
div.find_element_by_xpath('//*[@id="component-1250"]/div/table/tbody/tr/td[1]').click()
#hit calender date
browser.implicitly_wait(5)
browser.find_element_by_link_text(str(x)).click()
time.sleep(10)
try:
index = 0
while True:
header = browser.find_elements_by_class_name('x-ledgerdataview-header')
try:
time.sleep(5)
header[index].click()
while True:
name = browser.find_elements_by_class_name('x-lightcard-customer-name')
car = browser.find_elements_by_class_name('x-lightcard-vehicle-inf')
apt_time = browser.find_elements_by_class_name('x-lightcard-header-right')
contact = browser.find_elements_by_class_name('x-lightcard-contact')
note = browser.find_elements_by_class_name('x-lightcard-services')
try:
# print and write to file name/car/apt_time/contact/note
print(name[index].text)
f.write("n" + 'Name: ' + name[index].text + "n")
print(car[index].text)
f.write('Car: ' + car[index].text + "n")
print(apt_time[index].text)
f.write('Time: ' + apt_time[index].text + "n")
print(contact[index].text)
f.write('Contact: ' + contact[index].text + "n")
print(note[index].text)
f.write('Service Notes:' + note[index].text + "n")
print(x)
f.write('Date:' + x + "n")
break
except IndexError:
break
except IndexError:
x = x - 1
break
except NoSuchElementException:
x = x -1
print(x)
calender_changer(30)
time.sleep(5)
f.close()
login()
python beginner python-3.x web-scraping selenium
This is a Web scraping script I wrote to get data from my companies Appointment workbook into a text file so I can review each appointment that is made online through our website. The context is that I use the data in the text file to look up each appointment to get the car VIN and reschedule the appointment under my name. It saves me a lot of time using a script to get the data I need to get the Vin number of each car in every appointment.
Does this follow the common practices of Python scripts? Are nested loops common practice when making a script? The script also can be used for the Acura workbook with a change of one line, which I did to make a second Acura Script.
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
import time
def login():
#open text file to write
f = open('Honda_Appt_lists.text', 'w')
#find chrome Driver
browser = webdriver.Chrome('C:\Users\Eddie\Desktop\Script\chromedriver.exe')
#open browser to site
browser.get('https://login.xtime.com/')
#sleep to load full site
#Maximize window
browser.maximize_window()
time.sleep(5)
#Switch to the Iframe I need
browser.switch_to.frame('login')
#input login info and submit
browser.find_element_by_id('login').send_keys('username')
browser.find_element_by_id('password').send_keys('password')
browser.find_element_by_class_name('basic-button').click()
#sleep
time.sleep(5)
#Launch Honda
index = 0
while True:
honda = browser.find_elements_by_class_name('launch-button')
try:
index = index + 1
honda[index].click()
except IndexError:
break
time.sleep(10)
#Goes to workbook
#Applies Filters
browser.find_element_by_xpath('//*[@id="xt_common_header_button-1042"]').click()
time.sleep(10)
element = browser.find_element_by_id('button-1239-btnIconEl')
browser.execute_script("arguments[0].click();", element)
web_element = browser.find_element_by_xpath('//*[@id="treeview-1206-record-ext-record-163"]/td/div/span')
browser.execute_script("arguments[0].click();", web_element)
browser.find_element_by_xpath('//*[@id="button-1233-btnIconEl"]').click()
time.sleep(10)
#Sort by status
browser.find_element_by_xpath('//*[@id="button-1257-btnIconEl"]').click()
browser.implicitly_wait(5)
def calender_changer(x):
while x < 31 and x > 15:
#Find calender
div = browser.find_element_by_id('ledgerdateslider-1247-innerCt')
#hit calender
div.find_element_by_xpath('//*[@id="component-1250"]/div/table/tbody/tr/td[1]').click()
#hit calender date
browser.implicitly_wait(5)
browser.find_element_by_link_text(str(x)).click()
time.sleep(10)
try:
index = 0
while True:
header = browser.find_elements_by_class_name('x-ledgerdataview-header')
try:
time.sleep(5)
header[index].click()
while True:
name = browser.find_elements_by_class_name('x-lightcard-customer-name')
car = browser.find_elements_by_class_name('x-lightcard-vehicle-inf')
apt_time = browser.find_elements_by_class_name('x-lightcard-header-right')
contact = browser.find_elements_by_class_name('x-lightcard-contact')
note = browser.find_elements_by_class_name('x-lightcard-services')
try:
# print and write to file name/car/apt_time/contact/note
print(name[index].text)
f.write("n" + 'Name: ' + name[index].text + "n")
print(car[index].text)
f.write('Car: ' + car[index].text + "n")
print(apt_time[index].text)
f.write('Time: ' + apt_time[index].text + "n")
print(contact[index].text)
f.write('Contact: ' + contact[index].text + "n")
print(note[index].text)
f.write('Service Notes:' + note[index].text + "n")
print(x)
f.write('Date:' + x + "n")
break
except IndexError:
break
except IndexError:
x = x - 1
break
except NoSuchElementException:
x = x -1
print(x)
calender_changer(30)
time.sleep(5)
f.close()
login()
python beginner python-3.x web-scraping selenium
edited Jun 9 at 22:34
Jamalâ¦
30.1k11114225
30.1k11114225
asked Jun 9 at 15:23
BlackHazrd
14
14
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f196164%2fweb-scrape-appointment-workbook-to-a-text-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password