margo
margo

Reputation: 2927

Get data attributes with Nokogiri

I'm scraping a site that has a number of divs with the same ".pane" class and same "data-pane" data attributes.

input = doc.css('.pane[data-pane]')

How do I filter or select from the above to get the div which has a "data-pane" attribute equal to a specific value?

Upvotes: 1

Views: 2732

Answers (1)

matt
matt

Reputation: 79723

You can just treat it as you would any other attribute with the usual CSS syntax:

input = doc.css('.pane[data-pane="the value"]')

Upvotes: 4

Related Questions