Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Mar 2003
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question making code more effecient

    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:
    Code:
    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:
    Code:
    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!
    Last edited by havey; 02-04-2005 at 08:00 PM.

  • #2
    Regular Coder
    Join Date
    Mar 2003
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •