Extract Data From Webpage

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Extract Data From Webpage

Post by warrenk » Mon Apr 20, 2009 4:49 pm

I need to extract the values from a dropdown box on a webpage and load them into a dropdown field in Rev Studio. Is this possible with Rev Studio?

Thanks for any help!
Warren

dickey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Wed Apr 08, 2009 11:54 pm

Extract Data From Webpage

Post by dickey » Tue Apr 21, 2009 5:50 am

Hello Warren, I am new to Revolution Studio, but nonetheless there are several ways this task can be achieved in conjunction with Rev Studio.

1. the first question to ask of the solution is whether the <select></select> or drop list on the web site is populated with fixed options? - like:

Code: Select all

<html>
  <body>
    <form id="eg_form" action="eg_action.html" method="post">
      <select id="eg_select" name="">
        <!-- commonly selects start with a blank option -->
        <option id="0"></option>
        <option id="1">Red</option>
        <option id="2">Green</option>
        <option id="3">Blue</option>
      </select>
    </form>
   </body>
</html> <!-- etc etc -->
, or is the <select> populated with options that are the result of a dynamic process on the web page, such as being assigned based on the value in another <select> or <input> control, or are they perhaps database driven (an sql record set).

Your solution may therefore differ in each case, due to the nature of the way the <select> is updated on the web page. You may need to grab the options on opening your application (seldomly) or perhaps need to get the options live as you load a stack/substack/ or card as part of a transaction/program workflow (on call).

Fixed Options Scenario:

1. visit the target in your web browser and view source.
2. find the id of the element <select> you wish to target (write it down).
3. use the revBrowserGet command - see the documentation for the "htmltext" option, which extracts the
The html source of the current page being displayed.
4. write some code to handle the text, extracting either the id or option text between the <select id="your target id" and closing </select> tag.

Warren, if that scenario sounds like yours, that solution will work. If you need to obtain options from a dynamic page, I will post the second solution on request.

I hope you find this information helpful.

Kind regards, Andrew

warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Post by warrenk » Tue Apr 21, 2009 11:51 am

Andrew,

I really appreciate the time in explaining the process. I really appreciate your help. This is perfect!!! :D

Have a great day!
Warren

dickey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Wed Apr 08, 2009 11:54 pm

Extract Data From Webpage

Post by dickey » Tue Apr 21, 2009 2:20 pm

Thanks for your kind words Warren - I am just pleased I could help.

Kind regards, Andrew

Post Reply