Skip to content

Instantly share code, notes, and snippets.

@jcchurch
Created January 31, 2013 17:38
Show Gist options
  • Save jcchurch/4684667 to your computer and use it in GitHub Desktop.
Save jcchurch/4684667 to your computer and use it in GitHub Desktop.
import urllib
import sys
import re
troll = "dQw4w9WgXcQ"
urlsource = sys.argv[1]
f = urllib.urlopen(urlsource)
s = f.readlines()
f.close()
codes = []
names = []
for line in s:
m = re.search('data-video-id="([^"]+)', line)
if m:
codes.append( m.group(1) )
m = re.search('data-video-title="([^"]+)', line)
if m:
names.append( m.group(1) )
o = """
<html>
<head><title>Hi Jesse!</title></head>
<body>
<ul>
%s
</ul>
</body>
</html>
"""
x = ""
for i in range(len(codes)):
x += "<li><a href=\"http://www.youtube.com/watch?v=%s\">%s</a>\n" % (troll, names[i])
# Remove the above line and replace it with this to make the page work as intended.
# x += "<li><a href=\"http://www.youtube.com/watch?v=%s\">%s</a></li>\n" % (codes[i], names[i])
outfile = "out.html"
f = open(outfile, 'w')
f.write(o % x)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment