Windows Vista Forums

Reading text file at a URL
  1. #1


    Codeblack Guest

    Reading text file at a URL

    Hello,



    Is there way to read a text file which is located at a URL. for example
    http://www.abc.com/test/name.txt

    I want to read the contents of the text file which is available at the URL
    and copy the contents to another file locally.

    Thanks


      My System SpecsSystem Spec

  2. #2


    Codeblack Guest

    RE: Reading text file at a URL

    Does any one have any clue on this?

      My System SpecsSystem Spec

  3. #3


    Paul Randall Guest

    Re: Reading text file at a URL


    "Codeblack" <Codeblack@xxxxxx> wrote in message
    news:49258A75-03A4-47A1-A9F7-255377D4AF4B@xxxxxx

    > Hello,
    >
    > Is there way to read a text file which is located at a URL. for example
    > http://www.abc.com/test/name.txt
    >
    > I want to read the contents of the text file which is available at the URL
    > and copy the contents to another file locally.
    Why restrict your self to downloading text files?
    VBScript can easily download any type file, including password-protected
    files (if you know the username and password), by using the xmlhttp object
    included with most recent versions of Windows.

    Groups.google can give you a relatively short list of hits, so you don't
    have to wade through millions of useless info. Go to groups.google.com and
    paste the following into the search box:
    download file xmlhttp group:*.scripting.vbscript

    -Paul Randall



      My System SpecsSystem Spec

  4. #4


    vasuki.ramakrishna Guest

    Re: Reading text file at a URL

    Thanks for this. But is it possible to download a pdf file and save it
    as text file.

      My System SpecsSystem Spec

  5. #5


    T Lavedas Guest

    Re: Reading text file at a URL

    On Apr 1, 7:35*am, vasuki.ramakris...@xxxxxx wrote:

    > Thanks for this. But is it possible to download a pdf file and save it
    > as text file.
    Short answer is it can be downloaded from the URL, but it will still
    be a PDF - unless you have a PDF to Text converter to do that part of
    the job.

    The following routine will retrieve the file from the web ...

    Sub DownBinFile(FilePath, sURL)
    const adTypeBinary = 1
    const adModeReadWrite = 3
    const adSaveCreateOverwrite = 2
    ' Create an xmlhttp object:
    set oXML = CreateObject("MSXML2.XMLHTTP")
    oXML.open "GET", sURL, False
    oXML.send
    With CreateObject("ADODB.Stream")
    .type = adTypeBinary
    .mode = adModeReadWrite
    .open
    Do Until oXML.readyState = 4 : Wscript.Sleep 50 : loop
    .write oXML.responseBody
    .savetofile FilePath, adSaveCreateOverwrite
    End With ' ADODB.Stream
    End Sub

    The Filepath is the name and location where the result is to be
    stored, while sURL contains the full designation of the URL, including
    the http:// part. This could be used for ftp downloads as well, as
    long as the proper inline login syntax is provided as part of the sURL
    string.

    The conversion of the pdf is not part of my expertise, so you're on
    your own on that part.

    Tom Lavedas
    ***********
    http://there.is.no.more/tglbatch/

      My System SpecsSystem Spec

  6. #6


    HL0105 Guest

    Re: Reading text file at a URL

    On Apr 1, 7:04*am, T Lavedas <tglba...@xxxxxx> wrote:

    > On Apr 1, 7:35*am, vasuki.ramakris...@xxxxxx wrote:
    >

    > > Thanks for this. But is it possible to download a pdf file and save it
    > > as text file.
    >
    > Short answer is it can be downloaded from the URL, but it will still
    > be a PDF - unless you have a PDF to Text converter to do that part of
    > the job.
    >
    > The following routine will retrieve the file from the web ...
    >
    > Sub DownBinFile(FilePath, sURL)
    > * const adTypeBinary = 1
    > * const adModeReadWrite = 3
    > * const adSaveCreateOverwrite = 2
    > *' Create an xmlhttp object:
    > * set oXML = CreateObject("MSXML2.XMLHTTP")
    > * oXML.open "GET", sURL, False
    > * oXML.send
    > * With CreateObject("ADODB.Stream")
    > * * .type = adTypeBinary
    > * * .mode = adModeReadWrite
    > * * .open
    > * * Do Until oXML.readyState = 4 : Wscript.Sleep 50 : loop
    > * * .write oXML.responseBody
    > * * .savetofile FilePath, adSaveCreateOverwrite
    > * End With ' ADODB.Stream
    > End Sub
    >
    > The Filepath is the name and location where the result is to be
    > stored, while sURL contains the full designation of the URL, including
    > the http:// part. *This could be used for ftp downloads as well, as
    > long as the proper inline login syntax is provided as part of the sURL
    > string.
    >
    > The conversion of the pdf is not part of my expertise, so you're on
    > your own on that part.
    >
    > Tom Lavedas
    > ***********http://there.is.no.more/tglbatch/

    Free Text To PDF Converter:

    http://www.sanface.com/txt2pdf.html

    I use txt2pdf.exe in my scripts.

      My System SpecsSystem Spec

  7. #7


    T Lavedas Guest

    Re: Reading text file at a URL

    On Apr 6, 3:03*pm, HL0105 <tron9...@xxxxxx> wrote:

    > On Apr 1, 7:04*am, T Lavedas <tglba...@xxxxxx> wrote:
    >
    >
    >

    > > On Apr 1, 7:35*am, vasuki.ramakris...@xxxxxx wrote:
    >

    > > > Thanks for this. But is it possible to download a pdf file and save it
    > > > as text file.
    >

    > > Short answer is it can be downloaded from the URL, but it will still
    > > be a PDF - unless you have a PDF to Text converter to do that part of
    > > the job.
    >

    > > The following routine will retrieve the file from the web ...
    >

    > > Sub DownBinFile(FilePath, sURL)
    > > * const adTypeBinary = 1
    > > * const adModeReadWrite = 3
    > > * const adSaveCreateOverwrite = 2
    > > *' Create an xmlhttp object:
    > > * set oXML = CreateObject("MSXML2.XMLHTTP")
    > > * oXML.open "GET", sURL, False
    > > * oXML.send
    > > * With CreateObject("ADODB.Stream")
    > > * * .type = adTypeBinary
    > > * * .mode = adModeReadWrite
    > > * * .open
    > > * * Do Until oXML.readyState = 4 : Wscript.Sleep 50 : loop
    > > * * .write oXML.responseBody
    > > * * .savetofile FilePath, adSaveCreateOverwrite
    > > * End With ' ADODB.Stream
    > > End Sub
    >

    > > The Filepath is the name and location where the result is to be
    > > stored, while sURL contains the full designation of the URL, including
    > > the http:// part. *This could be used for ftp downloads as well, as
    > > long as the proper inline login syntax is provided as part of the sURL
    > > string.
    >

    > > The conversion of the pdf is not part of my expertise, so you're on
    > > your own on that part.
    >

    > > Tom Lavedas
    > > ***********http://there.is.no.more/tglbatch/
    >
    > Free Text To PDF Converter:
    >
    > http://www.sanface.com/txt2pdf.html
    >
    > I use txt2pdf.exe in my scripts.
    The OP was in need of a PDF to text converter.

    Tom Lavedas
    ***********
    http://there.is.no.more/tglbatch/

      My System SpecsSystem Spec

  8. #8


    Alex K. Angelopoulos Guest

    Re: Reading text file at a URL

    Here's a link for one of those; in fact, there are several handy PDF tools
    in the free Xpdf toolkit:

    http://www.foolabs.com/xpdf/download.html

    "T Lavedas" <tglbatch@xxxxxx> wrote in message
    news:cf68fdb1-e510-4a73-91a3-6fca2a478c69@xxxxxx

    > On Apr 6, 3:03 pm, HL0105 <tron9...@xxxxxx> wrote:

    >> On Apr 1, 7:04 am, T Lavedas <tglba...@xxxxxx> wrote:
    >>
    >>
    >>

    >> > On Apr 1, 7:35 am, vasuki.ramakris...@xxxxxx wrote:
    >>

    >> > > Thanks for this. But is it possible to download a pdf file and save
    >> > > it
    >> > > as text file.
    >>

    >> > Short answer is it can be downloaded from the URL, but it will still
    >> > be a PDF - unless you have a PDF to Text converter to do that part of
    >> > the job.
    >>

    >> > The following routine will retrieve the file from the web ...
    >>

    >> > Sub DownBinFile(FilePath, sURL)
    >> > const adTypeBinary = 1
    >> > const adModeReadWrite = 3
    >> > const adSaveCreateOverwrite = 2
    >> > ' Create an xmlhttp object:
    >> > set oXML = CreateObject("MSXML2.XMLHTTP")
    >> > oXML.open "GET", sURL, False
    >> > oXML.send
    >> > With CreateObject("ADODB.Stream")
    >> > .type = adTypeBinary
    >> > .mode = adModeReadWrite
    >> > .open
    >> > Do Until oXML.readyState = 4 : Wscript.Sleep 50 : loop
    >> > .write oXML.responseBody
    >> > .savetofile FilePath, adSaveCreateOverwrite
    >> > End With ' ADODB.Stream
    >> > End Sub
    >>

    >> > The Filepath is the name and location where the result is to be
    >> > stored, while sURL contains the full designation of the URL, including
    >> > the http:// part. This could be used for ftp downloads as well, as
    >> > long as the proper inline login syntax is provided as part of the sURL
    >> > string.
    >>

    >> > The conversion of the pdf is not part of my expertise, so you're on
    >> > your own on that part.
    >>

    >> > Tom Lavedas
    >> > ***********http://there.is.no.more/tglbatch/
    >>
    >> Free Text To PDF Converter:
    >>
    >> http://www.sanface.com/txt2pdf.html
    >>
    >> I use txt2pdf.exe in my scripts.
    >
    > The OP was in need of a PDF to text converter.
    >
    > Tom Lavedas
    > ***********
    > http://there.is.no.more/tglbatch/

      My System SpecsSystem Spec

Reading text file at a URL problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading A Text File vqthomf VB Script 2 19 Aug 2009
Reading file names and Searching for text Codeblack VB Script 11 22 Mar 2009
Reading a text file with StreamReader km .NET General 3 16 Oct 2008
Refresh on Reading more than one variable from a Text file OldDog VB Script 4 11 Sep 2008
Reading text file and charting them via powergadget IT Staff PowerShell 2 19 Mar 2008