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

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.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.