[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to Read Text from Webipage when its disabled

Md Rafiq

5/13/2009 3:26:00 PM

the webpage i m testing has many list box, text box, radio butons etc...
and it has Text field which is in Diabled and its not Text box;
eg:once after registering in website, the name field bcomes disabled and
its in Table format...

find the attached screen and element source Base Premimum...how to read
the datas and store it in exce,csv or anything

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML Strict//EN"><META
http-equiv="Content-Type" content="text/html; charset=utf-8"> <HTML
xmlns="http://www.w3.org/1999/xhtml"><BODY>...
class="width100"><TBODY><TR><TD class="noSurround"><TABLE
class="size100"><TBODY><TR><TD class="valignTop size100
noSurround"><TABLE class="size100"><TBODY><TR class="height100"><TD
class="valignTop"><FORM id="policyForm" name="policyForm"
action="/nw/policy/details/premium.xhtml" method="post" target=""><TABLE
class="data" style="WIDTH: 100%; BACKGROUND-COLOR: #c2c5ca"
cellSpacing="0" cellPadding="0" border="0"><TBODY><TR><TD><TABLE
class="table_style" cellSpacing="0" cellPadding="1"><TBODY
id="policyForm:_id69:tbody_element"><TR class="oddRow"> <TD
class="cell_align_right">$3,498.36</TD>
</TR></TBODY></TABLE></TD></TR></TBODY></TABLE></FORM></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY></HTML>
--
Posted via http://www.ruby-....

1 Answer

Mark Thomas

5/13/2009 4:21:00 PM

0

On May 13, 11:25 am, Rase In <mohamedra...@gmail.com> wrote:
> the webpage i m testing has many list box, text box, radio butons etc...
> and it has Text field which is in Diabled and its not Text box;
> eg:once after registering in website, the name field bcomes disabled and
> its in Table format...

A table is not the same thing as a disabled input control. However, it
doesn't really matter when all you want to do is extract the data.

> find the attached screen and element source Base Premimum...how to read
> the datas and store it in exce,csv or anything

You read the data the same way you'd read any HTML data, with an HTML
parser. First, you determine how to uniquely and consistently identify
the data you want to extract. Second, you construct an expression to
extract it.

I will provide an example using Nokogiri. Let's assume that you want
the dollar value that is always in the TD under the TBODY that has and
id of "policyForm:_id69:tbody_element". Here's what you can do:

doc = Nokogiri::HTML(html)
puts doc.search('//tbody[@id="policyForm:_id69:tbody_element"]/tr/
td').inner_html

-- Mark.