How to get a string from a webpage

P

PP

In my daliy work there are some project budget with the form "Between
$1,000 and $ 1200" to gather The html codes for this is as following.
What's more this part is in a table
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<tr><td valign="top" class="small" colspan="2"><b>Project Budget:</b>
Between $1,000 and $1,500<br><img src="/images/spacer.gif" height="5"
width="1" border="0"><br></td></tR>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Now I want to get the Budget in such pages normally more than 30. Can
any funtion get the whole string "Between $1,000 and $ 1,500" by a
regexp or something else.
I have tried the function " contains_text" but it returns a number.
Can anyone tell me what the number means and how can it get in touch
with the string I want
btw: the money is different but the form is always the same.

Can anyone help me ?
 
D

Dave Burt

PP said:
In my daliy work there are some project budget with the form "Between
$1,000 and $ 1200" to gather The html codes for this is as following.
What's more this part is in a table
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<tr><td valign="top" class="small" colspan="2"><b>Project Budget:</b>
Between $1,000 and $1,500<br><img src="/images/spacer.gif" height="5"
width="1" border="0"><br></td></tR>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Now I want to get the Budget in such pages normally more than 30. Can
any funtion get the whole string "Between $1,000 and $ 1,500" by a
regexp or something else.
I have tried the function " contains_text" but it returns a number.
Can anyone tell me what the number means and how can it get in touch
with the string I want
btw: the money is different but the form is always the same.

Can anyone help me ?

If you're using Watir (as I guess from your mention of contains_text)
then that number is probably an index into the string of the start of
that substring. So ie.text[n, 7], where n is the number you got from
ie.contains_text, should give you "Between" (7 characters).

Cheers,
Dave
 
B

Bret Pettichord

Don't use contains_text. Instead use a regexp directly:

/<b>Project Budget:</b> (Between \$[0-9,]* and \$[0-9,])<br>/ ~ ie.html
match = $1

or

/<b>Project Budget:</b> (Between \$[0-9,]* and \$[0-9,])<br>/ ~
ie.cell:)class, "small").html
match = $1
 
P

PP

Hi Bret
I have tried the method but it seems doesn't work. The error
information is about the "~". Could you show me some code more
particularly.

Best wishes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,206
Messages
2,571,069
Members
47,675
Latest member
RollandKna

Latest Threads

Top