def crawl(url):
html = getHTML(url) # getHTML() retruns HTTPResponse
print(html.read()) # PRINT STATMENT 1
if (html == None):
print("Error getting HTML")
else:
# parse html
bsObj = BeautifulSoup(html, "lxml")
# print data
try:
print(bsObj.h1.get_text())
except AttributeError as e:
print(e)
print(html.read()) # PRINT STAETMENT 2
What I don't understand is..
PRINT STATEMENT 1 prints the whole html whereas PRINT STATEMENT 2 prints only b''
What is happening here? ..I'm quite new to Python.