nwhawksfan

Attempting to extract data from table (Web Scraping)

Discussion created by nwhawksfan on Nov 23, 2012
Latest reply on Nov 25, 2012 by comment

Inthe attempt to prevent me throwing my MacBook out the window, I am posting this here.

 

I am pretty new to Filemaker, and maybe trying to bite off more than I can chew...story of my ilfe..

 

I have used the GetUrl script and pasted html data into a field called "url_g". In this HTML I am attempting to get some data out of 4 tables and put them in their respective fields.

 

I have tried numerous scripts to accomplish this, and am really struggling. A sample of the HTML code is below:

 

 

<tr class="ysprow1" align="right" height="16"><td class="yspscores" align="left"> 2010-11</td><td class="yspscores" align="left">ATL</td><td class="yspscores">77</td><td class="yspscores">34:17 </td><td class="yspscores">6.5</td><td class="yspscores">13.5</td><td class="yspscores">47.7</td><td> </td><td class="yspscores">0.7</td><td class="yspscores">2.0</td><td class="yspscores">33.1</td><td> </td><td class="yspscores">3.0</td><td class="yspscores">4.1</td><td class="yspscores">72.5</td><td> </td><td class="yspscores">1.7</td><td class="yspscores">6.8</td><td class="yspscores">8.5</td><td> </td><td class="yspscores">3.3</td><td class="yspscores">2.6</td><td class="yspscores">1.3</td><td class="yspscores">1.6</td><td class="yspscores">2.8</td><td class="yspscores">16.5</td><td> </td></tr>

 

Every number in this code needs to be placed in a particular field. To start I was simply trying to parse this text to a separate field so I could attempt to parse each number.

 

Now, I am here begging for help. Is this even possible? I watched a video of a somebody doing it, but he made assumptions I did not understand. I have googled "parse data" and most of the examples are very simple.

 

What I have tried is to Set a variable at word "ysprow1" and "ysprow2" (the beginning of the next table). I then attempted set a variable using the Middle function. I ran the script and it crashed FM.

 

Here is a copy of the script I was using last

 

 

#Parse the Tables out of the Code

#First Table
Loop

Go to Record/Request/Page[ First ]

Set Variable [ $t1beg; Value:Position ( NBA Players::url_g; "ysprowl1" ; 1 ; 1 ) ]

Set Variable [ $t1end; Value:Position ( NBA Players::url_g; "ysprowl2" ; 1 ; 1 ) ]

Set Variable [ $table1; Value:Middle ( NBA Players::url_g; $t1beg ; $1tend-$t1beg ) ]

Set Field [ NBA Players::url_l_table_1; $table1 ]

Go to Record/Request/Page

[ Next; Exit after last ]

End Loop

 

I know this is the part where experienced FM designers are laughing..I deserve it :) Any help would greatly be appreciated.

Outcomes