Page 1 of 1

Finding the unknown text 'x' chars to the right of the known

Posted: Fri Dec 04, 2009 3:02 pm
by Andycal
I'm trying to get the share price of certain stocks out of Yahoo. When you do a search (which is easy), I'm then loading it into a text box and filtering the web page to just get the line with the share details in, all good so far.

Here's an extract:

Code: Select all

<span style="color:#333333;">Share Price:</span> 62.35</td><td><span style="color:#333333;">Bid:</span>
Now, I want to extract the share price, so I need to get the value 8 characters to the right of the words 'Share Price'. Anyone know how to do that?

Re: Finding the unknown text 'x' chars to the right of the known

Posted: Fri Dec 04, 2009 3:38 pm
by dunbarx
Try this:

Code: Select all

on mouseUp
   get offset("share price",yourRawdata)
   put char (it + 20) to (it + 28) of yourRawdata into temp --should be enough room to grab the price
   
   repeat for each char tChar in temp --extract just numbers and dec. point
      if tChar is in "0123456789." then put tChar after SharePrice
   end repeat
   answer sharePrice
end mouseUp

Re: Finding the unknown text 'x' chars to the right of the known

Posted: Fri Dec 04, 2009 3:48 pm
by Andycal
Absolutely perfect!! Thanks bud, I definately owe you a pint for that bit of genius!