I'm using the package golang.org/x/net/html
to scrape data out of HTML pages and this has been working fine so far. However, I don't know how to extract data from a drop-down list like this:
<!DOCTYPE html>
<html>
<body>
<select name="car" size="1" id="car">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi" selected>Audi</option>
</select>
<select name="animal" size="1" id="animal">
<option value="dog">Dog</option>
<option value="cat" selected>Cat</option>
<option value="badger">Badger</option>
<option value="mouse">Mouse</option>
</select>
I want to extract the pre-selected options, so the result becomes this:
car = audi
animal = cat
How can I accomplish this? In case golang.org/x/net/html
is not capable of doing what I want, what else can I do to extract the data?