dirzuloo.blogg.se

Craigslist rss reader
Craigslist rss reader




craigslist rss reader craigslist rss reader

#Craigslist rss reader full#

Now that we have the feed in a format Ruby can easily use, we can call the #items method on it, which returns an array containing the feed’s articles as objects of class RSS::Rss::Channel::Item, then call each Item’s methods to access title, description, creator, etc., and a link to the full article.Īll of this turned out to be much easier than I was expecting, and I wanted to play around with RSS a little more, so I started building some methods to interact with a feed, then created an RSSFeed class and a command line interface to navigate and display the feed’s contents and open full articles in a browser. This parses the feed’s XML data into an object of class RSS::Rss and demonstrates calling #channel and #items to output the titles of the channel (Hi, Oleg!) and its recent articles: Title: Stories by Oleg Chursin on Medium Item: A Brief Introduction to Domain Modeling Item: Refactoring in Ruby Trying out the example code provided in the Ruby documentation shows off the basic functionality: url = open(url) do |rss| feed = RSS::Parser.parse(rss) puts "Title: #" end end require ‘rss’Ī quick search of for “rss” returns a couple hundred results, but all we need to get started (along with open-uri, so Ruby can open webpages) is Ruby’s standard library, which provides the ability to produce and consume feeds via the RSS module: require 'rss' require 'open-uri' Since I’m in the middle of writing my first post here, it doesn’t actually contain any articles yet, but you can see it already provides some basic information about my blog, and we’ll take a look at an actual post a bit later on.įirst, let’s get into how we can use Ruby to scrape an RSS feed from a website and turn it into something we can work with.






Craigslist rss reader