Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Reading text file at a URL

Reply
 
Old 03-13-2009   #1 (permalink)
Codeblack


 
 

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
Old 03-14-2009   #2 (permalink)
Codeblack


 
 

RE: Reading text file at a URL

Does any one have any clue on this?
My System SpecsSystem Spec
Old 03-14-2009   #3 (permalink)
Paul Randall


 
 

Re: Reading text file at a URL


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

> 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
Old 04-01-2009   #4 (permalink)
vasuki.ramakrishna


 
 

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
Old 04-01-2009   #5 (permalink)
T Lavedas


 
 

Re: Reading text file at a URL

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

> 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
Old 04-06-2009   #6 (permalink)
HL0105


 
 

Re: Reading text file at a URL

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

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

> > 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
Old 04-06-2009   #7 (permalink)
T Lavedas


 
 

Re: Reading text file at a URL

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

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

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

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

> > 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.
>
Quote:

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

> > 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
>
Quote:

> > 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.
>
Quote:

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

> > 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
Old 04-09-2009   #8 (permalink)
Alex K. Angelopoulos


 
 

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
Quote:

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

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

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

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

>> > 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.
>>
Quote:

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

>> > 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
>>
Quote:

>> > 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.
>>
Quote:

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

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

Thread Tools


Similar Threads
Thread Forum
Reading A Text File VB Script
Reading file names and Searching for text VB Script
Reading a text file with StreamReader .NET General
Refresh on Reading more than one variable from a Text file VB Script
Reading text file and charting them via powergadget PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46