how to read a text file on the internet?

S

Sun

I want to write an asp to read a text file from another web site.
Is it possible? how to do this??
if possible, please illustrate with the following code.

filename = server.mappath("textfile.txt")
Set fs = server.CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile(filename, 1, False)

Thanks
 
R

Roland Hall

in message : I want to write an asp to read a text file from another web site.
: Is it possible? how to do this??
: if possible, please illustrate with the following code.
:
: filename = server.mappath("textfile.txt")

This only references the server it runs on.

: Set fs = server.CreateObject("Scripting.FileSystemObject")
: Set thisfile = fs.OpenTextFile(filename, 1, False)

Try:

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
Dim objXML , strURL , strQuote
Set objXML = Server.CreateObject("MSXML2.XMLHTTP")
strURL = "http://www.microsoft.com/"
objXML.Open "GET" , strURL , False ,"",""
objXML.Send ""
strQuote = objXML.ResponseText
if len(strQuote) > 0 Then
Response.Write(strQuote)
else
Response.Write("No content received...")
end if
set objXML = nothing
%>

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
S

Sun

yes, thank you very much,
furthermore, I want to write it into a html file
how to do this with the XML object

Thanks again!!
 
S

Sun

yes, thank you very much,
furthermore, I want to write it into a html file
how to do this with the XML object

Thanks again!!
 
J

Jeremy Markman

Once you have the content, you can then use the filesystemobject to
create an HTML file on the server.

Jeremy
 
S

Sun

Thanks,
Where can I get more information about the MSXML object?
Since I found that it can't work with chinese content,
so, I want to find out the ways to solve it.
Thanks!!!
 
R

Roland Hall

in message : Thanks,
: Where can I get more information about the MSXML object?
: Since I found that it can't work with chinese content,
: so, I want to find out the ways to solve it.
: Thanks!!!

http://msdn.microsoft.com/library/d...ry/en-us/xmlsdk30/htm/xmobjxmlhttprequest.asp


--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top