Sebastian Delgado Sebastian Delgado - 10 months ago 50
Ruby Question

How to scrap only one specific ul with nokogiri?

I'm trying to get only the second ul element of this page, which is all the events list.

this is what i have right now:

require 'nokogiri'
require 'open-uri'

doc = Nokogiri::HTML(open('', {ssl_verify_mode: 0}))

doc.css('ul').each do |link|
puts link.content

the UL that i need is the second one present on the whole html document, how can i select only that one ?

Thanks for reading.


Try this


or if you want to use CSS selectors only