python download html as text

Solutions on MaxInterview for python download html as text by the best coders in the world

showing results for - "python download html as text"
Emma
07 Aug 2016
1import requests
2
3url = "https://stackoverflow.com/questions/24297257/save-html-of-some-website-in-a-txt-file-with-python"
4
5r = requests.get(url)
6with open('file.txt', 'w') as file:
7    file.write(r.text)
8
Hiba
20 Jul 2017
1import urllib.request    
2urllib.request.urlretrieve("http://www.example.com/test.html", "test.txt")
3