1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Pulling pages down via ASP

Discussion in 'Software' started by Dad, 6 Oct 2005.

  1. Dad

    Dad You talkin to me?

    Joined:
    15 Apr 2003
    Posts:
    5,375
    Likes Received:
    8
    Okay, here's the situation: I'm in the process of creating a brand spanking new Intranet site for the hospital I work for and want to include Health and Healthcare news stories from the AP. The problem is that 3/4 of the pc's in the hospital do not have access to the outside world, only the internal network, unless you sign on to the proxy. Most of the people who will want to read the news stories will not have authorization to sign on to the Internet and will not be able to read the story if I just use an RSS feed and link it up. Is there a way, using classic ASP, to pull the page down from the AP web site with the Intranet server and then display it on the client browser? I don't want to "rip" the story off the page, I want to be able to display the entire page, but using the Intranet server as a proxy. Does this make any sense?
     
  2. Hepath

    Hepath Minimodder

    Joined:
    20 Oct 2003
    Posts:
    730
    Likes Received:
    0
    I'm taking a shot in the dark here...

    Could you just not "Server.Execute()" or the external pages on your sever, hosting the result in a page to which users have access?

    Other than could you write a service on the server to poll the AP and save pages via XmlTranslation.....
     
  3. John Cena

    John Cena What's a Dremel?

    Joined:
    1 Jun 2004
    Posts:
    818
    Likes Received:
    0
    Have the main computer run as a IIS Server then as heppath said, write the server.execute on that server. Then have the other computers access the main computer like http://127.0.0.1/read.aspx?idstory=208
     
  4. Dad

    Dad You talkin to me?

    Joined:
    15 Apr 2003
    Posts:
    5,375
    Likes Received:
    8
    Unfortunetely the Server.Execute method wouldn't work for what I'm trying to do. I ended up writing the following script:

    Code:
    <%
    thisURL = request.QueryString("urlPath")
    		
    Set GetConnection = CreateObject("Microsoft.XMLHTTP")
    				 
    GetConnection.Open "get", thisURL, False
    GetConnection.Send 
    				
    ResponsePage = GetConnection.responseText
    				
    Response.write (ResponsePage)
    				
    Set GetConnection = Nothing
    %>
    and it's working 95% perfect. Instead of using the AP, I'm going to use WebMD as they have a cleaner layout and if you use "printing=true" as a url variable, you get a printing layout. The last problem that I'm running into is that the pages that I'm pulling have funky stuff going on before the BODY tag and it's messing up my page layout. If I can figure out a way to eliminate everything but what's in the BODY tag, it will be perfect.
     
  5. John Cena

    John Cena What's a Dremel?

    Joined:
    1 Jun 2004
    Posts:
    818
    Likes Received:
    0
    I don't see how Server.Execute would not work

    You have IIS on the main computer. Your script is there. Server.execue is executing relative paths...

    Now if the webpages are on a different computer, then server.execute wouldnt work

    The XMLHTTP object would work too but I hate creating Server side objects
     
  6. Hepath

    Hepath Minimodder

    Joined:
    20 Oct 2003
    Posts:
    730
    Likes Received:
    0

    Just have to parse the response...

    The response should have a 'text' property on it.. so....

    1. locate position of the string "<BODY>"
    2. locate position of the string "</BODY>"
    Create a string from within those positions?
     
  7. Dad

    Dad You talkin to me?

    Joined:
    15 Apr 2003
    Posts:
    5,375
    Likes Received:
    8
    That's exactly the problem. Essentially I guess I wanted to "screen scrape" the remote page, but not be back-handed about it. I wanted to keep the links in tact, any copyrights and text ads there as not to presume the article as my own.


    I actually was able to figure it out. Tool a little bit of doing, but here's what I came up with:

    Code:
    <%
    srvXmlHttp.open "GET", URL, false
    srvXmlHttp.send()
    					
    if srvXmlHttp.status = 200 Then
      result = srvXmlHttp.responseText
      beginpos =Instr(result,"<SPAN class=article-title>")
      result = replace(Mid(result,beginpos,len(result)), "/content",  "http://my.webmd.com/content")
      result = replace(result, "Original page:", "<center><font size=""-1"">Original page:")
      result = replace(result, "<td width=""50%"" valign=""top"">", "<td width=50% valign=top align=right>")
      result = replace(result, "width=""80%""", "width=""99%""")
      result = replace(result, "<SPAN class=article-title>", "<SPAN class=article-title><center>")
      result = replace(result, "<SPAN class=small-black-headline>", "<SPAN class=small-black-headline><center>")
      result = replace(result, "</SPAN><p></p>", "</center></SPAN>")
      result = replace(result, "<span class=article-byline>By", "<br><br><span class=article-byline>By")
      result = replace(result, "<SPAN class=article-byline>Reviewed", "<br><br><SPAN class=article-byline>Reviewed")
      result = replace(result, "<SPAN class=credits>&copy;", "<SPAN class=credits>Story &copy;")
      endpos = Instr(result,"All rights reserved.")
      result = Mid(result,1,endpos+19)
    				
      response.Write result
    end if
    					
    Set srvXMLHttp=Nothing
    %>
    By using the multiple REPLACE statements, I was able to lay it out to work with my design, plus preserve the links and copyrights from WebMD while eliminating any fancy page layout..
     
  8. Hepath

    Hepath Minimodder

    Joined:
    20 Oct 2003
    Posts:
    730
    Likes Received:
    0
    Excellent - glad you sorted it :)
     
  9. Dad

    Dad You talkin to me?

    Joined:
    15 Apr 2003
    Posts:
    5,375
    Likes Received:
    8
    Yea, sometimes it takes a kick in my butt to work it out.. ;)
     

Share This Page