cvanmeer Halfop
Joined: 02 Dec 2003 Posts: 40 Location: The Netherlands
|
Posted: Sat Mar 06, 2004 5:27 am Post subject: Grab 2 lines from WWW. Not working so good :S |
|
|
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: | | <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: | | <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: | 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 |
|