Scrubyt, a quick view:
Today I come up to Scrubyt, an excellent piece of code developed by Peter Szinek, Glenn Gillen and a bunch of other collaborators. What this software do is essentially fetch and operate on XML/HTML pages, here’s an example taken from the official website:
require 'rubygems'
require 'scrubyt'
ebay_data = Scrubyt::Extractor.define do
fetch 'http://www.ebay.com/'
fill_textfield 'satitle', 'ipod'
submit
record "//table[@class='nol']" do
name "//td[@class='details']/div/a"
end
end
puts ebay_data.to_xml
In this ten lines of code (including the two ‘require’ on top of the page) we fetch ‘ebay.com’ website, then we fill a textfield with the id ‘satitle’ with the text ‘ipod’ and we press the submit button. Next we create a container (named ‘record’) for each table with class ‘nol’ of the returning page (the page containing the results from our ‘ipod’ search) and we fill this container with a ‘name’ variable containing the text within an ‘A’ element incapsulated inside a td with class ‘details’.
If we print the result as xml (as we do in the last line) this will be the output (truncated):
USB 2.0 Sync Data Cable for iPhone 3G iPod Mini NanoPOWER SELLER-30 DAYS MONEY BACK GUARANTEE-FAST SHIPPING$1.99Free shipping22d 5h 50m
EnlargePIONEER 5.8" GPS NEW AVIC-F90BT DVD MP3 IPOD AVICF90BT!!! HAS THE NEW 2.0 UPDATE INSTALLED !!!!! 2.0 UPDATE$637.00Free shipping9d 5h 35m
...
In conclusion, this is a very nice and handy toy that can help us during deployment and test.
- Company:
- Person:
- Programming Language:
- Technology:
- Add new comment
- 112 reads
- Feed: railsonwave
- Original article


Recent comments
1 year 23 weeks ago
1 year 23 weeks ago
1 year 25 weeks ago
1 year 27 weeks ago
1 year 42 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 46 weeks ago
1 year 48 weeks ago