Forum: Ruby [FIXED, NOT ISSUE] Mechanize - Use with bad coded HTML

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fb17ca2e6314e82f74ccf23ce71c82ec?d=identicon&s=25 Brian Martínez (angelux)
on 2014-02-24 22:19
Hi, I'm new to Ruby and Mechanize and I'm making a script to update a
database based on the data scraped out of a website. This website is
badly coded and I don't have access to correct the issue, so I've been
having a lot of headaches because of it. My current issue is a select
tag with the selected attribute of the options. If I do a

  form.field_with(:name => 'my_select').value

 then the returned value is always the first value ignoring the selected
option. When I searched on the html code I see the selected option with
the attribute selected but with empty string, like so:

  <option value='my_value' selected=''>My Option</option>

I was wondering if there is a way to get all attributes from the option
node so I can look for the option that has the selected attribute even
if it's empty?

If this is a rookie question, please let me know, I've been searching
all over the web and can't find an explicit way.

Thanks
Fb17ca2e6314e82f74ccf23ce71c82ec?d=identicon&s=25 Brian Martínez (angelux)
on 2014-02-25 00:25
Never mind, it seems I'm not scraping correct page and I'm clicking the
wrong link. Thanks though.
This topic is locked and can not be replied to.