I’m trying to use Nokogiri to scrape a form’s select elements.
For example:
<select id="colors" name="colors">
<option class="" value="1">Blue</option>
<option class="" value="2">Green</option>
</select>
I would like 1 => 'Blue', 2 => 'Green', etc.
I tried using at_css and xpath but had no luck at all.
I guessed this would be the right track:
doc.at_css("#colors option").each do |d|
puts d
end
Which just gives me one:
value
I can get every option text on the page using xpath.
or as an object: