I am trying to download a file from a website using python and mechanize. My current code successfully logs on to the website and opens the page that contains the download link.
The download link is: https://www.lendingclub.com/browse/browseNotesRawDataV2.action
The info for the link is:
Link(base_url='https://www.lendingclub.com/browse/browse.action', url='/browse/browseNotesRawDataV2.action', text='', tag='a', attrs=[('class', 'master_pngfix'), ('id', 'browseDownloadAllLink'), ('href', '/browse/browseNotesRawDataV2.action')])
I use the follow_link method to click on the link:
br = mechanize.Browser()
br.follow_link(url='/browse/browseNotesRawDataV2.action')
However, nothing happens and no file is downloaded. When I open the link in my browser when I'm logged on, it pauses for a few seconds and downloads the file.
How can I download the file using Python?
For anyone who's interested, this was the solution:
br.retrieve('https://www.lendingclub.com/browse/browseNotesRawDataV2.action','loans.csv')[0]