seaofclouds (owner)

Fork Of

Revisions

gist: 21946 Download_button fork
public
Public Clone URL: git://gist.github.com/21946.git
Embed All Files: show embed
twitter_atom.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'rubygems'
require 'atom' # sudo gem install atom
require 'net/http'
require 'uri'
 
feed_url = 'http://search.twitter.com/search.atom?q=meh'
 
begin
  feed = Atom::Feed.new(Net::HTTP::get(URI::parse(feed_url)))
  feed.entries.each do |entry|
    puts "Title: #{entry.title}"
    puts "Description: #{entry.content.value}"
    puts "Link: #{entry.links.join(', ')}"
    puts "Date: #{entry.published}"
    puts '=' * 20
  end if feed
 
rescue Exception => ex
  puts ex.message
end
 
 
twitter_rss.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
 
feed_url = 'http://search.twitter.com/search.rss?q=meh'
 
begin
  content = "" # raw content of rss feed will be loaded here
  open(feed_url) do |s| content = s.read end
 
  rss = RSS::Parser.parse(content, false)
 
  rss.items.each do |item|
    puts "Title: #{item.title}"
    puts "Description: #{item.description}"
    puts "Link: #{item.link}"
    puts "Date: #{item.date}"
    puts '=' * 20
  end if rss
 
rescue Exception => ex
  puts ex.message
end