2018-11-27 IdHTTP1.Get nethttp

procedure TForm2.Button1Click(Sender: TObject);

var

    m,n:string;

    a: TstringStream;

begin

    a:= TstringStream.Create;

    IdHTTP1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Maxthon)';

    IdHTTP1.Get('https://music.163.com/#/song?id=33887645',a);

    m:=a.datastring;

    n:= UTF8Decode(m);

    memo1.Lines.add(n);    //在火狐中用查看元素,当歌曲播放时,是可以找到歌曲下载地址的。

end;

wwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

将TNetHTTPRequest和TNetHTTPClient组件放置在窗体上之后,将TNetHTTPRequest组件

的Client属性设置为TNetHTTPClient组件。

使用Get方法访问

使用TNetHTTPRequest的Get方法。

http://www.delphitop.com/html/kongjian/4807.html

procedure TForm1.Button1Click(Sender: TObject);

var

  Url: string;

  ResponseContent: TMemoryStream;

  Encoding: TEncoding;

begin

  URL := 'https://music.163.com/#/song?id=33887645';

  ResponseContent := TMemoryStream.Create;

  Encoding := TEncoding.GetEncoding(65001);

  NetHTTPRequest1.Get(Url, ResponseContent);

  Memo1.Lines.LoadFromStream(ResponseContent, Encoding);

end;

你可能感兴趣的:(2018-11-27 IdHTTP1.Get nethttp)