Results 1 to 4 of 4

Thread: Download and Parse Source

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521

    Download and Parse Source

    I usually don't do this, but I've had issues with looking up code for Javascript (it took me 4+ hours to figure out how to get a table cell to change bgcolor when the mouse was over it), so I'm gonna blatantly ask for some simple (I hope) code.

    In a nutshell, I would like this script to, on clicking a hyperlink, download the source code from a webpage (the URL is determined by putting the text of the URL in between two other strings), extract the text string that is between two other text strings, and display that text in a textbox or table cell.

    So, (I'm making up the objects and functions/using VB-style functions, but they should make sense):

    sURL = "const string 1" + hyperlink.text + "const string 2";
    sSource = DownloadSource(sURL);
    lStart = FindString(sSource, "const left string");
    lEnd = FindString(sSource, "const right string");
    sDisplay = SubStr(sSource, lStart, lEnd - lStart);
    TextBox.text = sDisplay;

    Thanks in advance.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You can't download source with JavaScript. You can set the source of a hidden iframe, but then you don't know how long it will take until you have the source available.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    It seems your are saying to open a hidden iframe, and then wait until I can see the </html> tag, then parse it? If so, could you provide some example code (unless it's much more complex than I made it out to be in my pseudo-code example).

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You could also do things in the loaded page's body.onload.

    You can access the parent document from within the iframe with
    window.parent.document
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width