[rails] RSS parsing with using Google API

Простая грабилка rss с блогов с помощью Google API.
Подробнее под катом.

Код позволяет взять полный json, с необходимыми rss-данными.

require 'rubygems'
require 'net/http'
require 'open-uri'
require 'json'

# setup needed path
SITE_URL = "http://some.domain.com/blog/feed/rss"

# parse json data into hash obj
json_data = JSON.parse(Net::HTTP.get(URI.parse(URL)))

# do with it whatever you want
json_data["items"].each do |value|
  puts "[*]#{value['enclosure'].first['href']}" unless value["enclosure"].nil?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s