Parsing Links
From: Whodat (someone_at_microsoft.com)
Date: 11/26/04
- Next message: Woef: "Re: Search files on remote computer"
- Previous message: Torgeir Bakken \(MVP\): "Re: Search files on remote computer"
- Next in thread: McKirahan: "Re: Parsing Links"
- Reply: McKirahan: "Re: Parsing Links"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 26 Nov 2004 18:03:13 -0500
Hi I have a script that someone helped me make. However it is just short of
what I need. The players data still has the html code around it. I want to
extract the name only with the statistics. I cant seem to get my head around
it - everything I have tried seems to come up with errors. Here is the
script.
I have left out my attempts at adding another Myvar mid statement that would
extract the player name. The script as you see it works.
<%
Dim objRead, objWrite, objShell, objXML, objFile, objFSO
Dim location, thisFolder, nbastats, strURL
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
Set ObjHttp = Server.CreateObject("Msxml2.XMLHTTP")
objHttp.Open "GET",
"http://www.tsn.ca/nba/Statistics.asp?category=Points&position=&division=&season=2005&type=player&endRow=520&startRow=1",
false
objHttp.Send
nbastats = objHttp.ResponseText
Set objHttp = Nothing
If Not objFSO.FileExists (Server.MapPath("nbastats.txt")) Then
objFSO.CreateTextFile (Server.MapPath("nbastats.txt"))
Set objFile = objFSO.GetFile(Server.MapPath("nbastats.txt"))
Set objWrite = objFile.OpenAsTextStream( 2,-2 )
'Response.Write( skaters )
'Response.End()
objWrite.Write( nbastats )
objWrite.Close()
Set objFile = Nothing
Set objWrite = Nothing
If Not objFSO.FileExists(Server.MapPath("csv.html")) Then
objFSO.CreateTextFile(Server.MapPath("csv.html"))
Set objFile = objFSO.GetFile(Server.MapPath("csv.html"))
Set objWrite = objFile.OpenAsTextStream( 2, -2 )
Set objFile2 = objFSO.GetFile(Server.MapPath("nbastats.txt"))
Set objRead = objFile2.OpenAsTextStream( 1, -2 )
MyVar = MID(nbastats, instr(1, nbastats, "bgcolor=""#F7EDE0""")-32,
LEN(nbastats))
MyVar = MID(MyVar, 1, instr(1, MyVar, "</table>")-1)
Dim myArray(17)
Dim ii 'col count
Do While instr(1, MyVar, "<tr") > 0
'// Now extract the 'record' from the table (like above code)
MyRec = MID(MyVar, instr(1, MyVar, ">")+1)
MyRec = MID(MyRec, 1, instr(1, MyRec, "</tr>")-1)
'// Now we should be left with all the <td>'s
ii = 0
Do while instr(1, MyRec, "<td") > 0
myValue = MID(MyRec, instr(1, MyRec, ">")+1)
myValue = MID(myValue, 1, instr(1, myValue, "</td>")-1)
'// We have successfully got a value from a <td>!
'// Maybe at this point you could load it into an array:
myArray(ii) = myValue
'// Now we have to clean the MyRec string up
MyRec = MID(myRec, instr(1, myRec, "</td>")+5)
ii = ii + 1
Loop
'// At this point we have a loaded myArray with all the values from the
record! You could build an SQL string at this point or anything really
objWrite.WriteLine Join(myarray,",") & "<br>"
response.Write ("All done")
'// Now we have to trim up the main string
Myvar = MID(MyVar, instr(1, MyVar, "</tr>")+5)
Loop
%>
</head>
<body>
</body>
</html>
I appreciate your input - thanks
- Next message: Woef: "Re: Search files on remote computer"
- Previous message: Torgeir Bakken \(MVP\): "Re: Search files on remote computer"
- Next in thread: McKirahan: "Re: Parsing Links"
- Reply: McKirahan: "Re: Parsing Links"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|