Using Selenium to extract ETF data from Cathay United Bank to Excel file with Safari.
- A Mac, so you could use Safari
- Allow "remote automation" in Safari
- Choose Safari > Preferences, and on the Advanced tab, select "Show Develop menu in menu bar."
- Choose Develop > Allow Remote Automation.
try:
- Set up web driver:Safari
- Open EFT website on Cathay United Bank
- New or open a excel file named Cathay-United-Bank-ETF.xlsx
- Initial Excel cell format
- Wait for website to load completely:until price of the last row not equal to "-"
- Extract
table
、thead
、tbody
- Write column title to Excel file, and set font to bold
- Write table data to Excel file:add new line on EFT name cell and price cell
- Save and close Excel file
- Quit web driver
except Exception:
- If an Excel file have been opened, close it
- If a web driver have been created, quit it
- Rerun main.py by
os.execv(sys.executable, ['python3'] + sys.argv)
This package is MIT licensed.