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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

fugee ohu
How can i find <li class="data-brand"> using nokogiri after running Nokogiri::HTML::Parse

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7a385ca7-3aaf-4a54-b283-8365bdff1fa0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Walter Lee Davis

> On Oct 16, 2018, at 4:19 AM, fugee ohu <[hidden email]> wrote:
>
> How can i find <li class="data-brand"> 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('li.data-brand').each do |elm|
  # do whatever with elm here
end

2. Get the first one in document source order:

elm = @doc.at_css('li.data-brand')

Walter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0CE4AAFD-13B1-4F69-A202-04F52C725937%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.