Let html
be an HTML string (say, the HTML source of this particular page). You can find the opening and closing tags with str.find()
. The string is converted to the lower case to allow case-insensitive search.
start = html.lower().find('<title>') + len('<title>')
end = html.lower().find('</title>')
You can then extract the part of the HTML string between the tags:
html[start:end]
#'How can I extract the title from a URL in Python without using any...'
2
solved How can I extract the title from a URL in Python without using any external module?