How to save web page as text file [Python] -
i save web page (all content) text file. (as if did right click on webpage -> "save page as" -> "save text file" , not html file)
i have tried using following code:
import urllib2 url='' page = urllib2.urlopen(url) page_content = page.read() file = open('file_text.txt', 'w') f.write(page_content) f.close()
my goal able save whole text without html code. (for example read "รจ" instead "é")
have @ html2text mentioned elsewhere
import urllib2 import html2text url='' page = urllib2.urlopen(url) html_content = page.read() rendered_content = html2text.html2text(html_content) file = open('file_text.txt', 'w') f.write(rendered_content) f.close()
Comments
Post a Comment