SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: ASPTear

  1. #1
    SitePoint Member
    Join Date
    Feb 2003
    Location
    Munich
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question ASPTear

    Good Morning,
    I have bought myself a book on ASP in order not to have to bug you with my silly questions, but now I am really struggling to get this NumberCells and GetCells function running on my machine (Win 2000 and IIS)
    To put it in a nutshell: I just get error messages! My plan was to build an overview page for stocks that would run locally on my machine.
    Well, I have installed the ASPTear.dll component in WINNT (http://www.alphasierrapapa.com/IisDe...nents/AspTear/). That worked quite well. Then I installed the IIS and it seems to run as well.

    Then I built an ASP -Site by paste and coying your code and saved it in the wwwroot-folder, so it can be published by IIS.
    Then I saved a Webpage by yahoo to my wwwrrot folder and called it Yahoo.asp (I want to test this whole thing first locally, since at home right now I dont have internet access.)
    This is what the page looks like:


    <%
    'extract.asp (c) 2000 Thomas Winningham - use freely!


    Function NumberCells("http://localhost/yahoo.asp")
    'Variables: ExtractUrl: The URL (eg http://www.cnn.com) to number
    'returns a string of the entire HTML document with numbers at the beginning
    'of each cell

    'Use the SOFTWING.AspTear component to get the HTML (but any will do...
    'just rewrite this part)
    'connection is including in Function for purpose of being self-contained
    Const Request_POST = 1
    Const Request_GET = 2

    Set xObj = Server.CreateObject("SOFTWING.AspTear")
    strRetVal = xObj.Retrieve("http://localhost/yahoo.asp",Request_GET,"","","")
    set xobj = nothing

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

    ' So long as <TD cells exist- number them
    Do while InStr(i, UCase(strRetVal), "<TD") > 0
    ' find next <TD
    i = InStr(i, UCase(strRetVal), "<TD")

    ' fomd the end of the <TD
    r = InStr(i, strRetVal, ">")
    strRetVal = left(strRetVal, r) & q & _
    right(strRetVal, len(strRetVal) - r)

    'Number the cells: the string equals all the html we've check,
    'our cell number, and then the html we've yet to check
    ' 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

    NumberCells = strRetVal
    End Function

    Function GetCell(cellnumber, "http/localhost/yahoo.asp")
    'Variables: Cellnumber: Number of the cell to get data from
    'ExtractURL: complete url that contains the cells and data
    'Returns a string of the cells data (including html)

    'Use the SOFTWING.AspTear component to get the HTML (but any
    'will do... just rewrite this part) connection is including in
    'Function for purpose of being self-contained
    Const Request_POST = 1
    Const Request_GET = 2

    Set xObj = Server.CreateObject("SOFTWING.AspTear")
    strRetVal = xObj.Retrieve("http://localhost/yahoo.asp",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

    ' Now... to find the end of this cell's text, we look for either <TABLE
    ' or <TD - whichever comes first (but we have to check if they exist or not)
    ' We don't include nested tables in the cell data because those tables have
    ' cells of their own.
    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

    %>


    Well, I hope I inserted the URLs right?

    Now, everytime I am trying to have my browser test the new ASp-page, I am getting this errormessage:


    Kompilierungsfehler in Microsoft VBScript- Fehler '800a03ea'

    Syntaxfehler

    /iisHelp/common/500-100.asp, line 129

    elseIf (objASPError.Description > "") Then
    ^
    Kompilierungsfehler in Microsoft VBScript- Fehler '800a03f2'

    Bezeichner erwartet

    /final.asp, line 2

    Function NumberCells("http://localhost/yahoo.asp")
    ---------------------^

    Component/WinInet error: Die Anmeldeanforderung wurde verweigert.


    Could you maybe tell me what this means and what I can do so this whole thing will work. This ASpTear Programme is not really clear to me either. It consist out of
    4 parts. one .dll, two .asps and one xcel, VB -code. I think that I just need the .dll part, but what about this VB-Code. Will I have to change it and will I have to insert it into the code
    so the programme wil run?

    Here is the link of the tutorial I am referring to
    http://www.4guysfromrolla.com/webtech/031000-1.shtml

    If I want to grab multiple cells from the same site, do I have to rewrite the GetCells Function for every cell I want to get?

    I know that I have loaded you with questions, but you really are my last help. Please let me know if you have any additional questiosn...
    Thanx,
    Jo

    Johannes Weber

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This looks weird:
    Function NumberCells("http://localhost/yahoo.asp")
    I mean; having a string value where you should have a parameter/variable name

    Isn't this the correct way to write it?
    Function NumberCells(strUrl)
    ...
    End Function

    And then use the function...
    strSomeVariable = NumberCells("http://localhost/yahoo.asp")



    And "The logon request was refused"?
    Guess that's just an effect of the previous syntax error


    Finally; why use ASPTear, when you can do the same thing with ServerXMLHTTP ?

  3. #3
    SitePoint Member
    Join Date
    Feb 2003
    Location
    Munich
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am sure you are right. And I will try it as soon as I get home tonight. I would like to stick to the ASPTear component, since I really dont know how to use the ServerXMLHTTP.

    What about the Visual Basic part of the ASPTear component. Will I have to include this into my code- or what does this do? (1 .dll part, 2 .asp parts and 1 VB part comes with the programme (ASPTear 1.0) at
    www.alphasierrapapa.com/ComponentCenter/AspTear
    This is the Visual Basic part:

    Option Explicit

    Const Request_POST = 1
    Const Request_GET = 2

    Sub DoTestComponent()
    On Error GoTo err_test_handler
    Dim xobj As Object, strRetval As String
    Set xobj = CreateObject("SOFTWING.ASPtear")

    ' URL, action, payload, username, password
    strRetval = xobj.Retrieve("http://194.8.136.100/formpost.asp", _
    Request_POST, "test=wille", "", "")
    Debug.Print strRetval

    Exit Sub
    err_test_handler:
    If Err.Number >= 400 Then
    MsgBox "Server returned error: " & Err.Number
    Else
    MsgBox "Component/WinInet error: " & Err.Description
    End If
    End Sub


    Is the
    strRetval = xobj.Retrieve("http://194.8.136.100/formpost.asp", _
    Request_POST, "test=wille", "", "")
    part, where I have to include my "http://localhost/yahoo.asp" ?

    Thank you!

  4. #4
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seems to me the VB/ASP parts are only examples, how to use the dll?
    I.e. what you need is the dll (and your own asp of course)
    And since it's ASP.old, you will have to register the dll

  5. #5
    SitePoint Member
    Join Date
    Feb 2003
    Location
    Munich
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Thank you so much!

  6. #6
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by weberhannes
    ...I really dont know how to use the ServerXMLHTTP.
    Not anymore!
    Code:
    <%@ Language=VBScript %>
    <%
    ' The page we want:
    strUrl = "http://localhost/test/page1.asp"
    On Error Resume Next
    ' Testing ASPTear, downloaded from
    ' http://www.alphasierrapapa.com/IisDe...nents/AspTear/
    ' Must be registered with "regsvr32 asptear.dll",
    ' otherwise CreateObject will fail ;)
    Const Request_POST = 1
    Const Request_GET = 2
    Set objTear = CreateObject("SOFTWING.ASPtear")
    strResponse1 = Server.HTMLEncode(objTear.Retrieve(strUrl, Request_GET, "", "", ""))
    If Err.Number <> 0 Then
     strResponse1 = "Server returned error: " & Err.Number & "<br>" & Err.Description
     Err.Clear
    End If
    ' Testing ServerXMLHTTP, for more info about MSXML, see
    ' http://msdn.microsoft.com/library/en...mloverview.asp
    Set objHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
    objHTTP.Open "GET", strUrl, False
    objHTTP.Send
    strResponse2 = Server.HTMLEncode(objHTTP.ResponseText)
    If Err.Number <> 0 Then
     strResponse2 = "Server returned error: " & Err.Number & "<br>" & Err.Description
     Err.Clear
    End If
    On Error Goto 0
    ' Display results:
    Response.Write "ASPTear returned:<br><pre>" & strResponse1 & "</pre>"
    Response.Write "ServerXMLHTPP returned:<br><pre>" & strResponse2 & "</pre>"
    %>

  7. #7
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And of course everyone notice the "error" in my example above?
    I never Set objTear = Nothing or objHTTP = Nothing
    Bad bad bad
    (But I don't want to edit the post, because then the links will be messed up...)

  8. #8
    SitePoint Member
    Join Date
    Feb 2003
    Location
    Munich
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You guys are geniouses in my eyes. Thanx
    See, Germany and the U.S are able to cooperate- at least in some cases

  9. #9
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Es ist korrekter zu sagen: Zusammenarbeit zwischen Deutschland und Schweden
    Last edited by jofa; Feb 27, 2003 at 11:59.

  10. #10
    SitePoint Enthusiast Phaed0's Avatar
    Join Date
    Apr 2003
    Location
    Phoenix, Arizona
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    jofa,
    Excellent. Thank You!


Bookmarks

Posting Permissions

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