Nokogiri and the name of a random div

Using Nokogiri and Ruby.

I have a parsing page with id div:

div id = "some-list-number ^ 875"

The number after ... - the number ^ changes randomly, and I just can't do

doc.css('#wikid-list-genres^875').each do |n|  
       puts n.text.to_s
end

But the basic structure is always the same - number ^ .. some numbers ...

So I need some kind of wild mask for these numbers.

How can I figure out using ruby ​​and Nokogiri?

Thank!

+3
source share
1 answer

You can use ^=to match the beginning of an attribute, for example. div[id^=wikid-list-genres]. (Source: W3C )

, id ^, , "wikid-list-genres ^ 875" , , . (: fooobar.com/questions/693/...) "wikid-list-genres-875" "wikid-list-genres_875"?

+6

Source: https://habr.com/ru/post/1725082/


All Articles