Created
August 14, 2008 10:08
-
-
Save metade/5399 to your computer and use it in GitHub Desktop.
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
require 'rubygems' | |
require 'feedalizer' | |
def six_music_hub | |
url = "http://www.bbc.co.uk/6music/events/hub/index.shtml" | |
f = feedalize(url) do | |
feed.title = "BBC 6 Music Hub Sessions" | |
feed.description = "Live sessions on BBC 6 Music" | |
scrape_items("a.watch") do |rss_item, html_element| | |
next if html_element.inner_html=='Watch the session and see the pictures' | |
link = "http://www.bbc.co.uk#{html_element.attributes['href']}" | |
rss_item.title = "#{html_element.inner_html} 6 Music Hub Session" | |
rss_item.link = link | |
rss_item.guid.isPermaLink = true | |
rss_item.guid.content = link | |
end | |
end | |
f.output | |
end | |
def six_music_news | |
url = "http://www.bbc.co.uk/6music/news/index.shtml" | |
f = feedalize(url) do | |
feed.title = "BBC 6 Music News" | |
feed.description = "News from BBC 6 Music" | |
links_parsed = [] | |
scrape_items("a", 100) do |rss_item, html_element| | |
link = "http://www.bbc.co.uk#{html_element.attributes['href']}" | |
next unless link =~ %r[/6music/news/\d+] | |
next if links_parsed.include?(link) | |
links_parsed << link | |
rss_item.title = (html_element/"//img").first.attributes['alt'] | |
rss_item.link = link | |
rss_item.guid.isPermaLink = true | |
end | |
@source = grab_page("http://www.bbc.co.uk/6music/news/archive.shtml") | |
scrape_items("a", 100) do |rss_item, html_element| | |
link = "http://www.bbc.co.uk#{html_element.attributes['href']}" | |
next unless link =~ %r[/6music/news/\d+] | |
next if links_parsed.include?(link) | |
links_parsed << link | |
rss_item.title = (html_element/"//img").first.attributes['alt'] | |
rss_item.link = link | |
rss_item.guid.isPermaLink = true | |
end | |
end | |
f.output | |
end | |
def live_lounge | |
url = "http://www.bbc.co.uk/radio1/livelounge/" | |
f = feedalize(url) do | |
feed.title = "BBC Radio 1 Live Lounge Hub Sessions" | |
feed.description = "Latest from the live lounge" | |
links_parsed = [] | |
scrape_items("//div.radio1_promo") do |rss_item, html_element| | |
link = "http://www.bbc.co.uk#{(html_element/"//a").first.attributes['href']}" | |
next if links_parsed.include?(link) | |
links_parsed << link | |
rss_item.title = "#{(html_element/"//img").first.attributes['alt']} - Live Lounge Session" | |
rss_item.link = link | |
rss_item.guid.isPermaLink = true | |
rss_item.guid.content = link | |
end | |
scrape_items("//td/div:eq(5)[@class='rh-links-rm']/ul/li/a") do |rss_item, html_element| | |
link = "http://www.bbc.co.uk#{html_element.attributes['href']}" | |
next if links_parsed.include?(link) | |
links_parsed << link | |
rss_item.title = "#{html_element.inner_html} - Live Lounge Session" | |
rss_item.link = link | |
rss_item.guid.isPermaLink = true | |
rss_item.guid.content = link | |
end | |
end | |
f.output | |
end | |
File.open(File.join(File.dirname(__FILE__),'bbc_feeds','6music_hub.rss'), 'w') { |f| f.puts(six_music_hub) } | |
File.open(File.join(File.dirname(__FILE__),'bbc_feeds','live_lounge.rss'), 'w') { |f| f.puts(live_lounge) } | |
File.open(File.join(File.dirname(__FILE__),'bbc_feeds','6music_music_news.rss'), 'w') { |f| f.puts(six_music_news) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment