0

Hi I am very new to python programming and I want a solution where I can download csv files from a website that requires you to log in using a username and password.

The code I have used to download csvs from non log in websites is the following:

    import urllib 
    url = "http://www.football-data.co.uk/mmz4281/1617/E0.csv"
    get = urllib.retrieve(url , "data.csv")
    get 

How would I need to change this code to download a csv from a log in website? The website I want to download the data from is an email service provider http://www.247emaildelivery.co.uk/index.php.

Any help would be really appreciated

Thanks

J Reza
  • 579
  • 1
  • 4
  • 5
  • You could try passing the username / password as form-filling fields, like the answer in [this](https://stackoverflow.com/questions/5667699/python-urllib2-automatic-form-filling-and-retrieval-of-results) question. Or, I think a better option is probably using a tool like [Selenium](http://selenium-python.readthedocs.io/) for python. You'd have to download the webdriver of the browser you want to use. But this is the most robust solution. There are lots of great examples in the selenium-python docs to get you started. – avery_laird Jul 21 '17 at 15:33
  • 1
    Read [How to "log in" to a website](https://stackoverflow.com/questions/11892729/how-to-log-in-to-a-website-using-pythons-requests-module) and [How to download](https://stackoverflow.com/questions/16694907/how-to-download-large-file-in-python-with-requests-py) – stovfl Jul 22 '17 at 08:02

0 Answers0