Created
July 25, 2010 22:01
-
-
Save bartvandendriessche/489927 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| require 'rubygems' | |
| require 'nokogiri' | |
| require 'open-uri' | |
| # script that will go over the railscasts website and create a list of | |
| # all available videos. (can then be used to download using wget or | |
| # something) | |
| def has_downloads?(doc) | |
| doc.css(".content").each do |content| | |
| if content.text.include?("No episodes found. ") | |
| return false | |
| end | |
| end | |
| return true | |
| end | |
| def get_railscasts_page(page) | |
| url = "http://railscasts.com/episodes?page=#{page}" | |
| Nokogiri::HTML(open(url)) | |
| end | |
| page = 1 | |
| begin | |
| doc = get_railscasts_page page | |
| doc.css(".download").each do |item| | |
| puts item.at_css("a").attribute("href") | |
| end | |
| page += 1 | |
| end until not has_downloads? doc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment