Skip to content

Instantly share code, notes, and snippets.

@LeonelF
Created June 2, 2021 11:07
Show Gist options
  • Save LeonelF/1505d81f08906b9c1af8a5e512d3ad99 to your computer and use it in GitHub Desktop.
Save LeonelF/1505d81f08906b9c1af8a5e512d3ad99 to your computer and use it in GitHub Desktop.
Grabs the title from a webpage
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