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 "&eacute")

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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -