SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Grabbing Table Columns from Other Web Pages

    hello all,

    i have seen one good script on net to grab the data from other webpage and i wanted to test for myself but i dont get the data instead of that, i get one empty page can anyone look at the code(i am so new to this remote scripting world)????

    <%
    Function GetCell(cellnumber, extracturl)
    '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(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

    ' 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



    Function NumberCells(extracturl)
    '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(extracturl,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
    %>


    if i look at the code, i cant see where they extract the url that is just a variable and i tried to put my url but i get empty page

    regardszzz

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if using ie you can export the table data into word or better yet excel..then you could have a database to edit it

  3. #3
    Guru Bullschmidt's Avatar
    Join Date
    Apr 2002
    Location
    USA
    Posts
    524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some related links:

    How do I read the contents of a remote web page?
    http://www.aspfaq.com/show.asp?id=2173

    Using Microsoft's XMLHTTP Object to Get Data From Other Web Pages by Richard Lowe - 11/1/2000
    http://www.4guysfromrolla.com/webtech/110100-1.shtml

    "Retrieve data from other web sites."
    How do I read the contents of a remote web page? - 5/2/2001
    http://www.aspfaq.com/faq/faqShow.asp?fid=119
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips


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
  •