Web address: http://caipiao.163.com/award/cqssc/20160517.html
This web page is netease web site lottery page, format is utf-8, how to quickly source code to get it out?? thank you
CodePudding user response:
Pay attention to the user-agent, directly in indy HTTP component can be directly obtained,
CodePudding user response:
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * access web page source code * * * * * * * * * * * *
The function GetWebPage (const Url: string) : string;
Var
Idp: TIdHTTP;//USES IDHttp
The begin
Result:=';
Idps:=TIdHTTP. Create (Application);
Try
Idp. HandleRedirects:=True;
Idp. Request. UserAgent:='Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon. The.net CLR 1.1.4322) ';
Result:=Utf8ToAnsi (UTF8Decode (idp) Get (Url)));
The finally
FreeAndNil (idp);
end;
end;
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * access web page source code * * * * * * * * * * * *
Procedure TForm1. Button1Click (Sender: TObject);
The begin
Memo1. Text:=getwebpage (' http://caipiao.163.com/award/cqssc/20160517.html ');
end;
Why the code to run can't get the source code, after, what's the problem? Temporarily suspended, please, thank you ~ ~ ~
CodePudding user response:
USES IdCompressorZLibEx
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * access web page source code * * * * * * * * * * * *
The function GetWebPage (const Url: string) : string;
Var
Idp: TIdHTTP;//USES IDHttp
The begin
Result:=';
Idps:=TIdHTTP. Create (Application);
Try
Idp. HandleRedirects:=True;
Idp.Com pressor:=TIdCompressorZLibEx. Create (nil);
Idp. Request. UserAgent:='Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon. The.net CLR 1.1.4322) ';
Result:=Utf8ToAnsi (idp) Get (Url));
The finally
FreeAndNil (idp);
end;
end;
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * access web page source code * * * * * * * * * * * *
CodePudding user response:
The