how to read a text file on the internet?

Discussion in 'ASP General' started by Sun, Apr 7, 2004.

  1. Sun

    Sun Guest

    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
    Sun, Apr 7, 2004
    #1
    1. Advertising

  2. Sun

    Roland Hall Guest

    "Sun" wrote in message news:...
    : 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
    Roland Hall, Apr 7, 2004
    #2
    1. Advertising

  3. Sun

    Sun Guest

    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!!
    Sun, Apr 7, 2004
    #3
  4. Sun

    Sun Guest

    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!!
    Sun, Apr 7, 2004
    #4
  5. Once you have the content, you can then use the filesystemobject to
    create an HTML file on the server.

    Jeremy

    On Wed, 7 Apr 2004 17:30:44 +0800, "Sun" <> wrote:

    >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!!
    >
    >
    Jeremy Markman, Apr 7, 2004
    #5
  6. Sun

    Sun Guest

    Thanks, I got it.

    "Jeremy Markman" <> ¼¶¼g©ó¶l¥ó·s»D
    :...
    > Once you have the content, you can then use the filesystemobject to
    > create an HTML file on the server.
    >
    > Jeremy
    Sun, Apr 8, 2004
    #6
  7. Sun

    Sun Guest

    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!!!


    "Roland Hall" <nobody@nowhere> ¼¶¼g©ó¶l¥ó·s»D
    :...
    > "Sun" wrote in message news:...
    > : 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
    >
    >
    Sun, Apr 8, 2004
    #7
  8. Sun

    Roland Hall Guest

    "Sun" wrote in message news:...
    : 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
    Roland Hall, Apr 8, 2004
    #8
  9. Sun

    Sun Guest

    Thanks again!!!

    "Roland Hall" <nobody@nowhere> ¼¶¼g©ó¶l¥ó·s»D
    :...
    > "Sun" wrote in message news:...
    > : 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/default.asp?url=/library/en-us/xmlsdk30/ht
    m/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
    >
    >
    Sun, Apr 8, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cmay
    Replies:
    0
    Views:
    1,113
  2. Krish
    Replies:
    1
    Views:
    1,061
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=
    Oct 20, 2005
  3. Mmcolli00 Mom
    Replies:
    2
    Views:
    186
    Mmcolli00 Mom
    Jan 27, 2009
  4. Alex Dowad
    Replies:
    4
    Views:
    257
    Michel Demazure
    May 1, 2010
  5. John Smith
    Replies:
    1
    Views:
    126
    Evertjan.
    Mar 12, 2005
Loading...

Share This Page