Delphi Net.HttpClient用最精简的代码获取网页数据


本文整理自网络,侵删。

 
program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  System.Classes,
  System.Net.HttpClient,
  System.RegularExpressions;

const
  url = 'http://www.delphitop.com/';
begin
  var http := THttpClient.Create;
  var sl := TStringList.Create;
  try
    sl.LoadFromStream(http.Get(url).ContentStream, TEncoding.ANSI);
    var m := TRegEx.Match(sl.Text, '<title>(.*?)</title>');
    if m.Success then
     writeln('获取信息: ', m.Value);
      Readln;
  finally
    sl.Free;
    http.Free;
  end;
end.

相关阅读 >>

Delphi 切换大小写的例子

Delphi cef4Delphi chromium1 设置user-agent

Delphi统计字数(汉字+字母+符号)

Delphi fmx 切换窗体最大化

Delphi 设计一个有渐变色的标签

Delphi中使用isuperobject解析json数据

Delphi 模仿qq截图

Delphi 字符串与内存流和文件的快速转换函数

Delphi closehandle的解释

Delphi firedac 下的 sqlite [11] - 关于批量提交 sql 命令的测试

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...