How can i find <li class="data-brand"> using nokogiri ?

How can i find

  • using nokogiri after running Nokogiri::HTML::Parse
  • Two options, both using the CSS syntax:

    @doc = Nokogiri::HTML.parse(...)

    1. Get all of the elements that match that selector:

    @doc.css('').each do |elm|
      # do whatever with elm here

    2. Get the first one in document source order:

    elm = @doc.at_css('')