My Code
browser = webdriver.Chrome()
browser.get(('https://www.barchart.com/options/most-active/etfs?viewName=main'))
downloadExcel = browser.find_element_by_class('bc-glyph-download')
downloadExcel.click()
I need to create a bot that will press the download button (class="bc-glyph-download") on the website: wwww.barchart.com every hour at 9, 10, 11, etc central time. This should download a saved CSV excel sheet on my desktop.
There were no stackoverflow articles on how to possibly do this that I saw. If this is going to be "hard", I may have to manually collect the excel sheets myself.
There is actually a very easy way to do this. You can use the Advanced Python Scheduler
module. Here is how:
from apscheduler.schedulers.blocking import BlockingScheduler
browser = webdriver.Chrome()
browser.get(('https://www.barchart.com/options/most-active/etfs?viewName=main'))
def tick():
downloadExcel = browser.find_element_by_class('bc-glyph-download')
downloadExcel.click()
print("Task completed")
if __name__ == '__main__':
scheduler = BlockingScheduler()
scheduler.add_job(tick, 'interval', hours=1)
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.