You don't need to use urllib.URLopener(), just use urllib.urlretrieve() instead as the following:
import urllib
urllib.urlretrieve("https://www.nseindia.com/products/content/historical/EQUITIES/2017/JUN?cm23JUN2017bhav.csv.zip8", "file.zip8")
You can also use wget:
import wget
wget.download("https://www.nseindia.com/products/content/historical/EQUITIES/2017/JUN?cm23JUN2017bhav.csv.zip8", "file.zip8")
And about automating it to download everyday, you can either use windows scheduler, or use a loop as the following:
import urllib
import time
while True:
urllib.urlretrieve('file', 'file')
time.sleep(86400) # 86400 seconds = 24 hours.
Answer from Mohd on Stack OverflowHow can I use python to pull a file off of a website? [need help]
How to Automate the File Download from This Site
Automate download in web using python - Stack Overflow
web scraping - How can I automate downloading files from a website using different inputs using Python? - Stack Overflow
I have a spreadsheet of direct links to a website that I want to download files from. Each link points to a separate page on the website with the download button to the file. How could I use python to automate this scraping process? Any help is appreciated.
This is the official page to view/download data for National Air Quality Index - India.
Here, we choose the date and hour, and a clickable link directly downloads a spreadsheet with data for that time-stamp.
Need ideas on how to automate that file download process in Python, so that we can download daywise and hourly data by specifying the date/hour range in the code.
Thanks in advance!