It's better to use
Without a parser can use string tool like eg
with open()
,when reading from disk that urllib.Without a parser can use string tool like eg
find()
,and slice out the text.import urllib.request resp = urllib.request.urlopen("file:///C:/Temp/test.html") html_file = resp.read().decode('utf-8') start = html_file.find("foo'>") + 5 end = html_file.find("</p") print(html_file[start:end])
Output:Hello world
def
means that you shall make function for this.