site = urllib.urlopen('https://www.youtube.com/watch?v=fT-iogyNhgE').read() m = re.findall('<meta property="og:image" content=(.*)>', site) urllib.urlretrieve(m, "picture.png") |
1 answer
In the variable m array of occurrences of the <meta property="og:image" content=(.*)> template <meta property="og:image" content=(.*)> In the site string, and urlretrieve expects the string.
import urllib import re site = urllib.urlopen('https://www.youtube.com/watch?v=fT-iogyNhgE').read() m = re.findall('<meta property="og:image" content=(.*)>', site) if m: url = m[0][1:-1] urllib.urlretrieve(url, "picture.png") - Thanks It works!!! - Mike
|