Created
July 11, 2009 20:44
-
-
Save 2bj/145388 to your computer and use it in GitHub Desktop.
get railscasts videos links from http://railscasts.com
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
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://www.anleger.blog