Reputation: 15
I am interested in downloading financial statements from the website Morningstar. Here there is an example of a page:
http://financials.morningstar.com/cash-flow/cf.html?t=PIRC®ion=ita&culture=en-US
On the top right there is the export to csv button, and I would like to click it with Python. Pressing inspection, I have this HTML tag:
<div class="exportButton">
<span class="icon_1_span">
<a href="javascript:SRT_stocFund.Export()" class="rf_export">
</a> ==$0
My idea was to use bs4 - BeautifulSoup to parse (not sure at all whether I need to parse it) the page and find the button to click it. Something like:
quote_page = pageURL
page = urlopen(quote_page)
soup = BeautifulSoup(page, "html.parser")
bs = soup.find(href="javascript:SRT_stocFund.Export()", attrs={"class":"rf_export"})
Obviously, this returns nothing. Do you have any suggestion on how could I tell to Python to export the data in the table? I.e. to automate the process of downloading the csv file instead of going on the webpage and doing it on my own.
Thank you very much!!
Upvotes: 1
Views: 1795
Reputation: 455
With the extension of google chrome "http trace", you can know, than it is a link:
It can do, with requests library.
I think, that it is the easy way (I think that if you modify the url parameter you can do the excel file as you want).
Regards!!!
Upvotes: 1
Reputation: 103
I would do it with Selenium WebDriver in "headless" mode. Try Selenium, it's quite easy to understand and use. :)
Upvotes: 0