||The best way to do this is to use the ServerXMLHTTP object which is included in most version of IIS and/or is downloadable from the Microsoft site.|
For a quick introduction to its capabilities, click here.
Perhaps the most important point not noted there is how to "hit" a site and send simulated <FORM> data.
If the site expects the data as part of the URL (that is, if a QueryString is normally used), then it's easy: Just use the full URL with querystring as part of the URL in the OPEN command:
objSrvHTTP.open "GET","http://www.aspmessageboard.com/forum/advanced.asp?F=27", False
But if you need to simulate a <FORM METHOD=POST> (that is, if the page you are hitting uses the equivalent of Request.Form to read the information), then you need to include the data as part of the Send method.
And the format you need to use is simple: Identical to the usual form of a query string! So, for example, to simulate the posting of a form such as this one:
<FORM Action="http://www.foo.com?process.asp" Method=Post>
you would write something like this:
info = "person=" & person & "&email=" & email
objSrvHTTP = Server.CreateObject ("MSXML2.ServerXMLHTTP")
Most of the rest of the information in this FAQ is obsolete. It has been retained for those who might not have access to current versions of IIS.
A typical version of this question might sound something like this:
Is there an easy way have an ASP script get an html file and pull data out of it? For example, could I have a script that goes to www.cnn.com (with their permission of course) and grabs the headlines so I can re-display them on my webpage?
The answer is: It's really easy, but... Unfortunately, you can't do it from "raw" ASP. You need a component to do the needed HTTP "spoofing" (that is, to pretend that it is just another web browser asking for info from the site). You can write your own component (and it's not overwhelmingly difficult, especially in Java with all the convenient I/O classes available, but it does require a knowledge of the HTTP protocol, at a minimum), but most people will find it a lot easier to purchase one of the third party components designed for this purpose.
Two components I know of are:
AspTear from Alpha Sierra Papa
AspHTTP from Server Objects.
Scott points out that there are articles on 4GuysFromRolla about using AspTear:
Grabbing Information from other Servers
Grabbing Table Columns from Other Web Pages
You can also use the freely availabe XMLHTTP component from Microsoft. An example of using this component can be seen below:
Dim objXMLHTTP, strReturn
Set objXMLHTTP = SErver.CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "GET", strURL, False
strReturn = objXMLHTTP.responseText
Set objXMLHTTP = Nothing
GetHTML = strReturn
' Write it:
' Download it:
Response.ContentType = "application/x-msdownload"
Response.AddHeader "Content-Disposition", "filename=Something.asp"
You can download the XMLHTTP component through:
the MSXML Beta!
Those two links appear to no longer be valid. Microsoft just loves reorganizing the MSDN site about every 3 to 6 months and invalidating any links you might have. As of 14 September 2001, at least, this link appears to get to the right place:
http://msdn.microsoft.com/downloads/sample.asp?url=/MSDN-FILES/027/001/680/msdncompositedoc.xml Good luck with it!