You can use the urllib library to fetch the html content of the url string and write it to a local file using file handling. Here's an example code snippet:
main.py204 chars11 lines
Explanation:
urllib.request
module to fetch the url data.urllib.request.urlopen()
and get the html content using response.read()
.open()
method in write mode and write the fetched html content to it using f.write()
method. We use "wb" mode for writing binary data to the file.gistlibby LogSnag