...

View Full Version : making code more effecient



havey
02-04-2005, 05:01 PM
Hi i'm using Thomas Winningham's script to scrap a page and set numbers to the page's cells so i can retreive the cell data for reformating on a page.asp
here's the scrapping:



Function GetCell(cellnumber, extracturl)

Const Request_POST = 1
Const Request_GET = 2

Set xObj = Server.CreateObject("SOFTWING.AspTear")
strRetVal = xObj.Retrieve(extracturl,Request_GET,"","","")
set xobj = nothing

i = 1 ' HTML Text Location Start
q = 1 ' Cell Number Start

' Loop until we have processed the cell we're looking for
Do until q > cellnumber
' Look for <TD the start of a cell
i = InStr(i, UCase(strRetVal), "<TD")

' Find the location of the end of the <TD tag
r = InStr(i, strRetVal, ">")

' Let the next loop start looking after this <TD tag we found
i = r + 1

' increase the count of which cell we're at
q = q + 1
Loop

' The start of our cell text is right after the last found tag
StartCellText = i

If (InStr(r, UCase(strRetVal), "<TABLE") > 0) AND _
(InStr(r, UCase(strRetVal), "<TABLE") < _
InStr(r, UCase(strRetVal), "</TD>")) then
ThisCellText = mid(strRetVal, StartCellText, _
InStr(r, UCase(strRetVal),"<TABLE")- StartCellText )
Else
ThisCellText = mid(strRetVal, StartCellText, _
InStr(r, UCase(strRetVal), "</TD>")- StartCellText )
End If

GetCell = ThisCellText
End Function



Currently since i need info from many cells, i'm doing this a lame programmers way, due to the lack of my skills:



variable44 = GetCell(44, "http://www.company.com/page.asp")
variable45 = GetCell(45, "http://www.company.com/page.asp")
variable47 = GetCell(47, "http://www.company.com/page.asp")
variable49 = GetCell(49, "http://www.company.com/page.asp")
variable57 = GetCell(57, "http://www.company.com/page.asp")
variable58 = GetCell(58, "http://www.company.com/page.asp")
variable60 = GetCell(60, "http://www.company.com/page.asp")
variable62 = GetCell(62, "http://www.company.com/page.asp")
.................i have a variable[number] all the way up to 1071, skipping certain cells that i don't need........................
variable1071 = GetCell(1071, "http://www.company.com/page.asp")


so how can things be so that variables are created with the cells info without making a request to the aspTear each time for each variable?

thanks!

havey
02-04-2005, 11:26 PM
used XML to grab the page and reduced the function to only 1 var. it works and about 4 times faster than the dll way



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum