1

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.

John Smith
  • 97
  • 8
  • 2
    So you want to run the script you've shown on the hour? `cron` probably suits your needs https://www.ostechnix.com/a-beginners-guide-to-cron-jobs/ – munk Jun 03 '19 at 20:24
  • Look here https://stackoverflow.com/questions/5677853/how-to-run-a-python-script-at-a-specific-times – user8426627 Jun 03 '19 at 20:27
  • I need to download the current ETF excel data every hour at 9, 10, 11, 12, 1, 2, and 3. This will automatically run automatically for several weeks, possibly months. – John Smith Jun 03 '19 at 20:27

1 Answers1

0

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
Arnav Poddar
  • 354
  • 2
  • 18