Hello again,
the html2text library really helped me and i want to understand every instruction of it, so the problem is
i really does not understand what is the goal of using sys.stdout in this code snippet.
and could i get rid of it
thank you in advance
for more information, we have made a short discussion about that in this topic:
the html2text library really helped me and i want to understand every instruction of it, so the problem is
i really does not understand what is the goal of using sys.stdout in this code snippet.
and could i get rid of it
Code:
import sys, urllib
from StringIO import StringIO
import html2text
if __name__ == '__main__':
url = '[URL unfurl="true"]http://www.fsmb.org'[/URL]
encoding = 'utf-8'
f = urllib.urlopen(url)
try: s = f.read()
finally: f.close()
ustr = s.decode(encoding)
b = StringIO()
old = sys.stdout
try:
sys.stdout = b
html2text.wrapwrite(html2text.html2text(ustr, url))
finally:
sys.stdout = old
text = b.getvalue()
b.close()
print text
thank you in advance
for more information, we have made a short discussion about that in this topic: