Parsing Links

From: Whodat (someone_at_microsoft.com)
Date: 11/26/04


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



Relevant Pages

  • Re: Script commands to populate the details tab on a file
    ... Here's a VBScript only solution... ... ' Begin Script ... Sub ChangeFileProperties ... Set objFile = CreateObject ...
    (microsoft.public.windows.server.scripting)
  • merge CSV to excel
    ... Can anybody help me withe this script. ... I want comma seperated files import it to excel. ... Const ForReading = 1 ... Set objfile = objFSO.GetFile ...
    (microsoft.public.scripting.vbscript)
  • Re: Decoding html pages
    ... the HTML code that the PHP engine produces *from* the raw html code and that ... That's the case with practically any PHP "page" (or any by a ... server-side script generated page for that matter). ... Of course the script does load, when you load the proper page (else it would ...
    (comp.lang.javascript)
  • Re: Deleting log files
    ... get the script to work properly when I am attempting to test them. ... & vbcrlf & vbcrlf ... Set ObjFile = ObjFS.GetFile ... Set oFSFile = oFS.OpenTextFile(strObjTopFolderPath & ...
    (microsoft.public.scripting.vbscript)
  • Re: HTML Code Produced by FP
    ... The OP is not using a script - he is designing a page that will be ... In pages I write that will be parsed by a Perl script I do not allow ... FrontPage to write any code. ... FP puts breaks (inserts html code) in places in the actual ...
    (microsoft.public.frontpage.programming)

Loading