idhttp用代理IP获取网页源码

procedure TForm1.btn1Click(Sender: TObject);
var
    Http:TIdHTTP;
begin
    Http := TIdHTTP.Create(nil);
    Http.ProxyParams.ProxyServer := '91.211.141.249'; //代理IP
    Http.ProxyParams.ProxyPort := 8080;
    Http.ProxyParams.ProxyUsername := '';
    Http.ProxyParams.ProxyPassword := '';

    //百度和GG屏蔽了idhttp控件,所以需要修改请求头
    Http.Request.UserAgent := 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15';


    mmo1.Text := Http.Get( 'http://www.baidu.com' );
    FreeAndNil( Http );

end;

你可能感兴趣的:(idhttp用代理IP获取网页源码)