python - AttributeError: 'HTTPResponse' object has no attribute 'replace' -
hi above error. why pop up, missing , how around ? thanks
try: import urllib.request urllib2 except importerror: import urllib2 html2text import html2text sock = html2text(urllib2.urlopen('http://www.example.com')) htmlsource = sock.read() sock.close() print (htmlsource)
im running idle 3.4.3 on windows 7 os.
html2text
expects html code passed in as string - read response:
source = urllib2.urlopen('http://www.example.com').read() text = html2text(source) print(text)
it prints:
# example domain domain established used illustrative examples in documents. may use domain in examples without prior coordination or asking permission. [more information...](http://www.iana.org/domains/example)
Comments
Post a Comment