zoukankan      html  css  js  c++  java
  • delphi请求idhttp数据

    idhttp

      ss : TStringStream;
    begin
      ss := TStringStream.Create('', TEncoding.GetEncoding(936)); { 指定gb2312的中文代码页,或者54936(gb18030)更好些 utf8 对应 65001}
      try
        IdHTTP1.Get(CSURL, ss);
        IdHTTP1.Get(CSURL);
        Memo1.Text := ss.DataString;
      finally
        ss.Free;
      end;
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    var
    params:tstrings;
    begin
    idHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
    idHTTP1.Request.ContentType:='application/x-www-form-urlencoded; Charset=UTF-8';
    idHTTP1.Request.Host:='my.qq.com';
    idHTTP1.Request.Connection:='Keep-Alive';
    idHTTP1.Request.Accept:='*/*';
    idHTTP1.Request.SetHeaders;
    idHTTP1.Request.CustomHeaders.Values['Cookie']:= edit4.text;
    Params:=TStringList.Create;
    params.Add('fp='+'loginerroralert');
    params.Add('u='+edit1.Text);
    params.Add('p='+edit2.Text);
    params.Add('verifycode='+edit3.Text);
    params.Add('u1='+'http://my.qq.com');
    params.Add('aid='+'8000203');
    params.Add('dummy='+'1');
    params.Add('h='+'1');
    memo1.Text:=idhttp1.Post('http://ptlogin2.qq.com/login',params);
    memo1.Text:=utf8toansi(memo1.Text);
    end;
    void __fastcall TForm6::Button1Click(TObject *Sender)
    {
        TStringStream *stream;
        stream = new TStringStream();
        this->IdHTTP1->Get("http://www.beijing-time.org/time15.asp", stream);
    
        this->Caption = stream->Size;
        Memo1->Text = stream->DataString;
        delete stream;
    }
    
    // ---------------------------------------------------------------------------
    void __fastcall TForm6::Button2Click(TObject *Sender)
    {
        TStringStream *stream;
        stream = new TStringStream();
        this->NetHTTPClient1->Get("http://www.beijing-time.org/time15.asp", stream);
        this->Caption = stream->Size;
        Memo1->Text = stream->DataString;
        delete stream;
    }
  • 相关阅读:
    题解 SP27102/UVA1747 【Swap Space】
    题解 P1453 【城市环路】
    题解 P5587 【打字练习】
    题解 P5594 【【XR-4】模拟赛】
    git add 的一点说明
    理解 Git 的基本概念 ( Merging Collaborating Rebasing)
    windows 上 Python 通过 SCP 连接linux server
    Neo4j CQL | WITH用法
    Neo4j CQL |create &merge
    Item 4: Prefer Interpolated F-Strings Over C-style Format Strings and str.format(请使用f-string格式化字符串)
  • 原文地址:https://www.cnblogs.com/cb168/p/4793687.html
Copyright © 2011-2022 走看看