This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Grab 2 lines from WWW. Not working so good :S

Old posts that have not been replied to for several years.
Locked
c
cvanmeer
Halfop
Posts: 40
Joined: Tue Dec 02, 2003 1:00 pm
Location: The Netherlands
Contact:

Grab 2 lines from WWW. Not working so good :S

Post by cvanmeer »

Hi guys,

I want to strip some data from a webpage.
Now the problem is, the data I want, is always in de the same line, but not in the exact same place at all times.
My problems concerns 2 lines:

Line 1:

Code: Select all

<tr><td bgcolor=#B8C5E2 align=right> </td><td bgcolor=#C9D3E9>Total number of page views up till now</td><td nowrap bgcolor=#C9D3E9>145683</td></tr>
Line 2:

Code: Select all

<tr><td bgcolor=#B8C5E2 align=right> </td><td bgcolor=#C9D3E9>6 March 2004</td><td align=right bgcolor=#C9D3E9>342</td></tr>
I suspect line 1 is the easiest. I want to grab the total number of page views. In this example: 145683
The way I do this now (and not working correctly) is this:

Code: Select all

 set url1 "http://www.nedstatbasic.net/s?tab=1&link=1&id=2532130"
 set temp1 [http::geturl $url1 -timeout 5000]
 set data1 [http::data $temp1]
 set stap1 [split $data1 \n]
 set l1stap2 [lindex $stap1 115]
 set l1stap3 [string range $l1stap2 0 [expr [strlen $l1stap2]-11]]
 set l1stap4 [string range $l1stap3 137 end]
 set hits $l1stap4
I think it has to be a sort of regexp, but I don't know how.

The second line is the most variable, because of the changing data in the line. In this example line I want to capture: 342

Could someone help me?

thx.

Chrizz
Locked