Re: get a textfile from website into memo
- From: "MikeB" <m.byerleyATVerizonDottieNettie>
- Date: Thu, 22 Nov 2007 19:08:41 -0500
He could also simply use vbscript or jscript that is already on his machine and
HTTP Request like (this one hacked a bit from michael harris):
watch for wrap Just call the Script from your Delphi code :
'Begin VBScript
download
"http://wm.atlrec.com/Trans-Siberian_Orchestra/new_03/xmas_sarajevo_timeless-300.wmv","C:\Temp\Hold.wmv"
Sub Download(sSource,sDest)
Dim oHttp
dim Stream
dim Start
dim fso
dim OldName
dim i
Const adModeReadWrite = 0
const adTypeBinary = 1
const adSaveCreateOverwrite = 2
stop
'wait a while for closing the file
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(Sdest) then
OldName = Sdest & ".old"
if fso.fileexists(OldName) then fso.DeleteFile (OldName)
fso.MoveFile Sdest ,OldName
end if
'Set oHttp = CreateObject("Microsoft.XMLHTTP")
Set oHttp = CreateObject("MSXML2.ServerXMLHTTP")
'Set oHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
'Set oHttp = CreateObject("WinHttp.WinHttpRequest")
oHttp.Open "GET", sSource, False
oHttp.send
Set Stream = CreateObject("adodb.Stream") 'my error
Stream.Type = adTypeBinary
Stream.Mode = adModeReadWrite
Stream.Open
Stream.write oHttp.responseBody
Stream.SaveToFile sDest, adSaveCreateOverwrite
Stream.Close
msgbox "Download Finished"
Set oHttp = Nothing
Set Stream = Nothing
end sub
'End VBScript
"Jamie" <jamie_ka1lpa_not_valid_after_ka1lpa_@xxxxxxxxxxx> wrote in message
news:keo1j.56$Mc.53@xxxxxxxxxxxxxxx
frits wrote:
Can I be given a direction how to read a textfile from my website into adown load the ICS "Internet Component Suite" and use the
memo (using http)
to put it into the very basics: (of course this does not work but to get the
idea)
memo1.Lines.LoadFromFile('http://www.mysite.org/mydir/myfile.txt);
(I could not copy it from webbrows component)
(Delphi 5)
Frits v/d Laan
Netherlands
ThttpClient component which will directl down load the file
you want. From there, you do what you want with it.
If you want to copy it from the Twebbrowser component, I
also have code for that how ever, that is more of less a
waste of space unless you're using the component for other
things in your app ?
Below are some examples of getting text.
procedure TForm1.Button1Click(Sender: TObject);
Var
V,V2:OLEVariant;
begin
V := WebBrowser1.Document;
memo1.Clear;
try
Memo1.Lines.Add(V.Body.innerText);
Except
end
end;
procedure TForm1.Button2Click(Sender: TObject);
Var
V:Variant;
begin
V := Webbrowser1.Document;
Memo1.Clear;
Try
Memo1.Lines.ADd(V.Body.OuterText);
Except
End;
end;
--
"I'm never wrong, once i thought i was, but was mistaken"
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5
.
- References:
- get a textfile from website into memo
- From: frits
- Re: get a textfile from website into memo
- From: Jamie
- get a textfile from website into memo
- Prev by Date: Re: get a textfile from website into memo
- Next by Date: Re: Feature Request: Case statement needs improved default syntax
- Previous by thread: Re: get a textfile from website into memo
- Next by thread: Re: get a textfile from website into memo
- Index(es):