{
***函数名 : GetHttpsHtml
***函数说明: 获取当前页面的Html源代码
***参数 :
sPageURL: 页面URL地址
bState : 成功状态
***返回值 : 返回成功状态(True表示成功,False表示失败)
}
function GetHttpsHtml(sPageURL: string; var bState: Boolean): string;
var
sStream: TStringStream;
hInt, hUrl: HINTERNET;
Buffer: PChar;
dwRead: Cardinal;
begin
try
sStream := TStringStream.Create('');
try
GetMem(Buffer, 65536);
hInt := InternetOpen('Delphi', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
dwRead := 0;
hUrl := InternetOpenUrl(hInt, PChar(sPageURL), nil, 0, INTERNET_FLAG_RELOAD, 0);
repeat
InternetReadFile(hUrl, Buffer, 1000, dwRead);
if dwRead <> 0 then
sStream.Write(Buffer^, dwRead);
until dwRead = 0;
InternetCloseHandle(hUrl);
InternetCloseHandle(hInt);
FreeMem(Buffer);
bState := True;
Result := sStream.DataString;
finally
sStream.Free;
end;
except
on e:Exception do
begin
bState := False;
Result := e.Message;
end;
end;
end;