Skip to content

Instantly share code, notes, and snippets.

@heycarsten
Created September 12, 2009 18:39
Show Gist options
  • Save heycarsten/185932 to your computer and use it in GitHub Desktop.
Save heycarsten/185932 to your computer and use it in GitHub Desktop.
# Now all I have to do is make it work :-/
scraper do |doc|
doc.css('.user-details', :on_missing => :halt) do |n|
n.css('.name') do |nn|
nn.emit do |content|
first, last = *content.split
{ :first_name => first, :last_name => last }
end
end
n.css('.age').emit(:age, :format => [/[0-9]+/, :to_i])
n.css('.address').emit(:address, :format => [:strip])
n.css('.country-code').emit(:country, :format => [:country_code_to_name])
end
doc.css('.user-job-history ul li').all(:job_histories) do |li|
li.css('.company-name').emit(:company, :format => [:titlecase])
li.css('.job-title').emit(:title)
li.css('.job-timeframe').emit_using(:job_dates)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment