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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts

    Generated html into a variable

    Is there any way to get the asp page to load an external file's generated html into a variable?

    i am trying to get stats from a site that isnt mine (its php btw) so i can display them in another way without all the crap inbetween so i really need to be able to get sections of the page into their own variables, but i assume that i should get the whole page's html into a variable and split it or something

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    With .Net you should be able to instantate a browser window (server side) navigate to a web site and then extract anything you want from the web page it brings up. I know I saw a post just last week about an XML object which could be used for this but I can't find that post right now.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    can you be a little more clear than that please, i do not want to refresh it or anything jsut get certain parts from the page

    like if the page to get it from had a table containing this:
    Code:
    <tr>
      <td width="50%"><b><font size="1">Number of Penguins</font></b>&nbsp;</td>
      <td width="50%"><b><font size="1">42</font></b>&nbsp;</td>
    </tr>
    <tr>
      <td width="50%" bgcolor="#808080"><b><font size="1">Number of Hippos</font></b></td>
      <td width="50%" bgcolor="#808080"><b><font size="1">57</font></b>&nbsp;</td>
    </tr>
    how would i get the numbers of each animal into their own variables on the page that the asp is run from?
    so i could write:
    Code:
    Penguins: <%=NoOfPenguins%><br>
    Hippos: <%=NoOfHippos%>
    and get an output of:
    Penguins: 42
    Hippos: 57
    Last edited by ghell; 12-16-2003 at 05:56 PM.

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The example is in javascript and is also client side but there's nothing that keeps you from making it vbscript and running it server side. The biggest difference is that you wouldn't be running it every little bit, it'd only be run when your page is loaded but once it's run you'll have that web page loaded into an object where you can extract the values you want.


    Untested code:
    Code:
    sub getWebPage(urlIn)
      dim xmlhttp
      set xmlhttp = server.createobject("Microsoft.XMLHTTP")
      xmlhttp.Open("GET", urlIn, false)
      xmlhttp.send()
      if (xmlhttp.status = 200) then
        ... code to extract the data you want goes here
      else
        ... code to handle a lack of response or an error goes here
      end if
    end sub
    Use the XML DOM to find and extract the data: http://msdn.microsoft.com/library/de...ttprequest.asp
    Last edited by Roy Sinclair; 12-16-2003 at 07:11 PM.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #6
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    just btw, i completely and utterly suck at vb

    i could maby use that js on the other page but i need to know what to replace
    parent.window.frames[2].document.getElementById('chat-box').innerHTML = xmlhttp.responseText;
    with from my table html that i wrote earlier

    btw, ty for all ur help in both my recent posts roy

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you're not good at VB, don't bother to learn it just code your ASP pages using javascript.

    As for getting the data you want, the xmlhttp object can be thought of as the "window" object, just drill down to the objects you want just as if it were on a client browser because in fact that's what you're doing. The xmlhttp object is an instance of a browser which you created and told to load the referenced web page, then you can use the xmlhttp object to gain access to any of the objects in that browser window and therefore add them to your ASP page. Am I making any sense to you here?
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #8
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    ok, v long thread and i still cant get it to work.. starting to get frustrated now...

    if i make 2 pages:
    the page with the original stats (originalStats.htm)
    Code:
    <html>
    <head>
    <title>Page With All the Original Stats on</title>
    </head>
    <body>
    <table>
    	<tr>
    		<td width="50%"><b><font size="1">Number of Penguins</font></b> </td>
    		<td width="50%"><b><font size="1">42</font></b> </td>
    	</tr>
    	<tr>
    		<td width="50%" bgcolor="#808080"><b><font size="1">Number of Hippos</font></b></td>
    		<td width="50%" bgcolor="#808080"><b><font size="1">57</font></b> </td>
    	</tr>
    </table>
    </body>
    </html>
    and the page which should get variables from the other page and display them
    Code:
    <html>
    <head>
    <title>Page that should display 42 and 57</title>
    </head>
    <body>
    <script>
    <!--
    function getMessages(){
      var xmlhttp;
      var responseText = '';
      if (ActiveXObject) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
        xmlhttp.Open("GET", "originalStats.htm", false); 
        xmlhttp.send();
        if (xmlhttp.status==200){
          document.getElementById('noideawhatgoeshere').innerHTML = xmlhttp.responseText;
        }
      }
    }
    //-->
    </script>
    </body>
    </html>
    what do i need to change in the 2nd page and what am i doing wrong..now... see.. if you cna answer this as directly as possible, correct and test my code so that the 2nd page comes out how i want it, and tell me how to do it!

    plz dont refer me to any manuals that dont help, tell me to go through a window object (thats just obvious) or anything like that... i dont care about the working, i just need a solution using the code i give in this post

    thanks

  • #9
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post
    You can only use the XML DOM if the HTML page is valid XML (which it won't be unless it's actually XHTML).

    Instead you should use regular expressions to parse the file and retrieve the parts you need.
    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"

  • #10
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    Instead you should use regular expressions to parse the file and retrieve the parts you need.
    such as...

    i know im stupid and everything but isnt that what i asked help with in the first place

  • #11
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post

    Thumbs down

    There's no need to be self-deprecating, get frustrated, or to take that attitude.



    We are here to help you find a solution but judging from your previous posts in this thread (where you say you don't know VB and don't want to be directed to reference material), what you are asking for is a solution presented to you on a platter.

    I can't speak for Roy, but I am not here to spend my time developing code for free for other people who show no willing to improve their own abilities. I am here to act as a facilitator, helping others learn new things and enhancing their understanding and competence with various aspects of the systems and languages that they work with, sometimes providing some demo code, and on very rare occasions getting someone 99% of the way there if it's particularly complicated or if someone really has been trying but hasn't quite grasped something.

    Perhaps somebody else will do all the work for you, but I'm not going to...
    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"

  • #12
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    I'm not going to do all the work either..
    If you don't want this link, then there's nothing more I can do to help you.

  • #13
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    ok m@rco, 1st of all.. nuts to you...now i feel a bit better..
    I DIDNT WANT THE WHOLE CODE DONE OR ME, I WENT AND BOUGHT A BOOK ON VISUAL BASIC AND EVERYTHING, I MEAN, I DONT BUY ANYTHING.. BUT I BOUGHT THIS BOOK ANYWAY!!!

    well, all i wanted was my code to be corrected and ammended or some1 to tell me why it isnt working and what i need to do to fix it, glen is usualy a great help but if i knew how to do it i wouldnt be asking now would I?!?

  • #14
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post
    Originally posted by ghell
    ok m@rco, 1st of all.. nuts to you...
    A mature response as expected. Glad you managed to sort it out yourself in the end.
    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"

  • #15
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    Originally posted by M@rco
    A mature response as expected. Glad you managed to sort it out yourself in the end.
    well, sarcasm isnt very mature so you cant comment on my maturity

    anyway, just had to release my anger without punching anything/one or swearing

    even so, you have assured me that what i ask CAN be done in asp on your site marcustucker.com in which you say:
    "ASP scripts can manipulate data from databases, XML, pages on other web sites, user-entered information, uploaded files, and any other source you can think of" so, you do know how to do it, you are just not telling me...and yet you are apparently some kind of guru???
    Last edited by ghell; 12-29-2003 at 06:53 PM.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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