Idhttp.get (aurl:string): string;//return string
Idhttp.get (aurl:string; Aresponsecontent:tstream)//return stream
The second type of return stream is more applicable based on the different encoding formats of the website
1 functionHttpgetbystr (URL:string):string;2 begin3Fidhttp: = Tidhttp.create (Nil);4 Try5Fidhttp.connecttimeout: = the;6Fidhttp.readtimeout: =6000;7Result: =Fidhttp.get (URL);8 finally9 Fidhttp.disconnect;Ten Freeandnil (fidhttp); One End; A End;
1 functionTsearchlrcthread.httpgetbystream (URL:string; aencoding:tencoding)2 : Tstringstream;3 begin4Result: = Tstringstream.create ("', aencoding);5Fidhttp: = Tidhttp.create (Nil);6 Try7Fidhttp.connecttimeout: = the;8Fidhttp.readtimeout: =6000;9 Fidhttp.get (FURL, Result);Ten finally One Fidhttp.disconnect; A Freeandnil (fidhttp); - End; - End;
Based on the Unicode version, different aencoding are set according to the different encoding of the website. Type, return the datastring encoding format will be normal, no garbled situation
Idhttp Get method