Solved

Get contents from other web site

Posted on 2014-01-23
9
436 Views
Last Modified: 2014-02-05
I need to get contents from other web site a display it on the screen.  I have the following code:

dim url, xmlhttp
    url = "http://www.cpms.osd.mil/WageData/wagedata"
    set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
     xmlhttp.open "GET", url, false
    xmlhttp.setRequestHeader "Content-Type", "text/HTML"
   xmlhttp.Send
   
        Response.write (xmlhttp.responseText)
    set xmlhttp = nothing


I'm getting this error:

We have encountered an error on this page.  
 
An 500;100 ASP Error encountered.

Error (-2147012867): A connection with the server could not be established
 
It looks like it's because the firewall.  Is there a way to get around it or if there's another way to display data from other web page?

Thanks,
0
Comment
Question by:ttta83
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39805101
Hi,
I think this is not the connection/firewall because you get a response - an IIS error 500.
What happens if you copy that URL and open e.g. Internet Explorer on the server where you host your ASP web site and open that url? You probably should get the same result.
Is there a difference when you open that url in your local browser?
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39805422
Are you sure this is on your server? MSXML2.ServerXMLHTTP.6.0

Try

url="http://www.cpms.osd.mil/WageData/wagedata"
 Set xmlHttp =  Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
    xmlHttp.Open "GET", url, False
    xmlHttp.setRequestHeader "User-Agent", "asp httprequest"
    xmlHttp.setRequestHeader "content-type", "application/x-www-form-urlencoded"
    xmlHttp.Send
    getHTML = xmlHttp.responseText
  set xmlHttp = Nothing
response.write getHtml

Open in new window

or
url="http://www.cpms.osd.mil/WageData/wagedata"
 Set xmlHttp =  Server.CreateObject("MSXML2.ServerXMLHTTP")
    xmlHttp.Open "GET", url, False
    xmlHttp.setRequestHeader "User-Agent", "asp httprequest"
    xmlHttp.setRequestHeader "content-type", "application/x-www-form-urlencoded"
    xmlHttp.Send
    getHTML = xmlHttp.responseText
  set xmlHttp = Nothing
response.write getHtml

Open in new window

0
 

Author Comment

by:ttta83
ID: 39806618
Rainer Jeschor,

I got "The page cannot be displayed" when I tried to open the URL in IE on the server.  It works fine in my local browser.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ttta83
ID: 39806627
Scott Fell,

I checked regedit and MSXML2.ServerXMLHTTP.6.0 is on the server.

I tried both of your examples and got the same error:

     An 500;100 ASP Error encountered.
     Error (-2147012867): A connection with the server could not be established

I tried them on different web and got this:

     msxml3.dll error '80072efd'
     A connection with the server could not be established

However both work in my personal web (host by GoDaddy).  

Thanks,
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39806662
I just tested this on my server and it worked.

if it is not working, are you sure classic asp is turned on?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Dim aRequest
Set aRequest = CreateObject ("Microsoft.XMLHTTP")
aRequest.Open "GET","http://www.cpms.osd.mil/WageData/wagedata",False
aRequest.Send
response.write aRequest.responseText
%>

Open in new window

0
 

Author Comment

by:ttta83
ID: 39806764
Scott,

I tested your latest code on the server and got:

  msxml3.dll error '800c0005'
  The system cannot locate the resource specified.

Does it have anything to do with the firewall in my company?  Is there another way to get data from other web page?

Thanks for your help!.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39806816
Firewalls and networking is not my expertise.

In a pinch you can frame it.

<style>
iframe{
   width:600px;
   height:500px;
}
</style>
<!-- place below in your body section and style tags in your head section -->
<iframe src="http://www.cpms.osd.mil/WageData/wagedata">Frames are not supported</iframe>

Open in new window

0
 

Author Comment

by:ttta83
ID: 39837264
Scott,

The problem is the firewall setting.  

I added the line below and the network team added the exception rule for it to work.

     xmlHttp.setProxy 2, "http=ourdomain:portnumber", ""

Thank you very much for your help!
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39837516
Thank you for the update.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question