0

I would like to open and copy an excel file (.xls) from a website in python.

I have the following code below:

import requests 

page = requests.get("https://fred.stlouisfed.org/series/IC4WSA")

from bs4 import BeautifulSoup

soup = BeautifulSoup(page.content, 'html.parser')

for link in soup.find_all('a'):
print(link.get('href'))

I have located string characters representing the href link to the excel file in the print line.

I would like to be able to open the excel workbook associated with the href and transfer the contents of the excel workbook to another excel workbook. If possible I might also like to run a VBA macro to affect the updated excel workbook.

My question: how do I select and open the excel file using python and once open tranfer the data to another workbook or run a vba subroutine to create a final product? Overall I am trying to build a simple and effective scraper of excel files with python. If there are other structures or logical approaches I am interested to hear of those too.

Thanks!

ShadowRanger
  • 143,180
  • 12
  • 188
  • 271
SBF12345
  • 75
  • 1
  • 2
  • 10

0 Answers0