Reputation: 20297
I am attempting to download a lot of files from http://www.sl.universalservice.org/funding/opendatasearch/Search1.asp using the Python library mechanize. On the site, the user must fill out 2 ASP forms, and then when the user clicks the second submit button, a file download starts. I was able to get the Python program to go through both forms, but I do not see how to get the file. How can I access the file once I submit the second form?
Upvotes: 0
Views: 598
Reputation: 40370
With b as your browser object:
b.submit() # The second of the two forms
c = csv.DictReader(b.response(), dialect='excel-tab')
b.response() gives you access to a file-like object, which can be processed by the csv module.
Upvotes: 1