在Delphi 10.3.3 Pro中使用Indy获取域名的到期日期,可以按照以下步骤进行:
uses
System.SysUtils, IdHTTP, IdGlobal;
function GetDomainExpirationDate(domain: string): TDateTime;
var
http: TIdHTTP;
response: string;
expirationDate: string;
dateString: string;
begin
http := TIdHTTP.Create(nil);
try
response := http.Get('http://whois.domaintools.com/' + domain);
expirationDate := Copy(response, Pos('Expiration Date:', response) + 16, 10);
dateString := Copy(expirationDate, 5, 2) + '/' + Copy(expirationDate, 7, 2) + '/' + Copy(expirationDate, 1, 4);
Result := StrToDate(dateString);
finally
http.Free;
end;
end;
procedure Main;
var
domain: string;
expirationDate: TDateTime;
begin
domain := 'example.com'; // 替换成你要查询的域名
expirationDate := GetDomainExpirationDate(domain);
WriteLn('Domain: ', domain);
WriteLn('Expiration Date: ', FormatDateTime('yyyy-mm-dd', expirationDate));
end;
begin
try
Main;
except
on E: Exception do
WriteLn('Error: ', E.Message);
end;
end.
在上述代码中,我们通过发送HTTP GET请求到 "http://whois.domaintools.com/" 加上要查询的域名,然后从响应中提取到期日期信息。注意将 "example.com" 替换为你要查询的域名。
请注意,以上代码仅适用于获取域名到期日期的简单示例,并且依赖于网站 "http://whois.domaintools.com/" 的特定HTML结构。对于其他域名查询需求,可能需要根据不同的WHOIS服务提供商进行修改。
腾讯云没有直接提供针对域名到期日期的相关产品。但可以使用腾讯云的DNS解析产品(DNSPod)来管理域名解析,并通过其他方式获取域名的到期日期信息。具体的相关产品信息和介绍,请参考腾讯云的官方文档:https://cloud.tencent.com/document/product/302
请注意,本回答所提供的内容仅供参考,具体实现可能需要根据实际需求进行调整和修改。
领取专属 10元无门槛券
手把手带您无忧上云