Created
November 27, 2012 16:53
-
-
Save BruceHubbard/4155441 to your computer and use it in GitHub Desktop.
Nokogiri Examples
This file contains hidden or 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
Nokogiri::HTML.parse(open(url)).css('.tn a').collect {|img| img["href"]} | |
#open(url) - opens and returns an html document | |
#css('selector') is just like jquery except server side. It returns a (ruby equivalent of a) linq-like enumerable | |
#collect is the same as .NET's select function | |
#So this one line when I set url to a Craigslist listing detail page will open that page and return an array of images for that listing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment