用IdHTTP.get 獲取網頁內容報錯 intercept value is not valid
用這兩個函式
function StrPas(const Str: PChar): string;
begin
Result := Str;
end;
function GetWebPage(const Url: string):string;
var
Session,
HttpFile:HINTERNET;
szSizeBuffer:Pointer;
dwLengthSizeBuffer:DWord;
dwReserved:DWord;
dwFileSize:DWord;
dwBytesRead:DWord;
Contents:PChar;
begin
Session:=InternetOpen('',0,niL,niL,0);
HttpFile:=InternetOpenUrl(Session,PChar(Url),niL,0,0,0);
dwLengthSizeBuffer:=1024;
HttpQueryInfo(HttpFile,5,szSizeBuffer,dwLengthSizeBuffer,dwReserved);
GetMem(Contents,dwFileSize);
InternetReadFile(HttpFile,Contents,dwFileSize,dwBytesRead);
InternetCloseHandle(HttpFile);
InternetCloseHandle(Session);
Result:=StrPas(Contents);
FreeMem(Contents);
end;
呼叫GetWebPage 有的能抓取成功 有的抓過來顯示為空
哪位幫忙看看什么問題 或者有什么別的辦法抓取網頁資料指點下
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/91719.html
標籤:網絡通信/分布式開發
上一篇:Unary模式下客戶端創建 default-executor 和 resolver-executor 執行緒和從啟動到執行grpc_connector_connect的主要流程
下一篇:第三章、處理資料
