Created
June 2, 2021 11:07
-
-
Save LeonelF/1505d81f08906b9c1af8a5e512d3ad99 to your computer and use it in GitHub Desktop.
Grabs the title from a webpage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.parse | |
import requests | |
response = urllib.request.urlopen('https://www.youtube.com/watch?v=-IYfwCWZeD0') | |
for line_number, line in enumerate(response): | |
#print('line: '.format(line)) | |
if "<title>" in str(line): | |
tmp = str(line) | |
tmp = tmp.split("<title>",1)[1] | |
tmp = tmp.split("</title>",1)[0] | |
print('Title line: {0}'.format(tmp)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment