Skip to content

Instantly share code, notes, and snippets.

@2bj
Created July 11, 2009 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2bj/145388 to your computer and use it in GitHub Desktop.
Save 2bj/145388 to your computer and use it in GitHub Desktop.
get railscasts videos links from http://railscasts.com
#!/usr/bin/env python
import urllib
import re
import os
# @author 2bj (gml2bj gmail)
# @target чиста для себя ;) ну и учу питон
class railcasts_grabber:
url = 'http://railscasts.com/episodes?page=%d'
def __init__(self, total_pages=1):
for i in reversed(range(1, total_pages+1)):
for link in self.get_links(self.get_page(i)):
m = re.search(r'/videos/([0-9]+)_', link)
print link,'-',m.group(1)
# os.system('pumpkg "'+link+'" "Railscast video #'+m.group(1)+'"')
# pumpkg - http://gist.github.com/142355
def get_page(self, page_num):
f = urllib.urlopen(self.url % page_num)
s = f.read()
f.close()
return s
def get_links(self, page_html):
p = re.compile(r'href="([^"]+\.mov)"')
return reversed(p.findall(page_html))
#grabber = railcasts_grabber(17)
@Utterer
Copy link

Utterer commented Jul 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment