Delphi使用JSON解析调用淘宝IP地址库REST API 示例
淘宝IP地址库:http://ip.taobao.com,里面有REST API 说明。
Delphi XE 调试通过,关键代码如下:
- var
- IdHTTP: TIdHTTP;
- RequestURL: string;
- ResponseStream: TStringStream;
- JO, JData: TJSONObject;
- begin
- IdHTTP := TIdHTTP.Create(nil);
- IdHTTP.ReadTimeout := 0;
- IdHTTP.AllowCookies := True;
- IdHTTP.ProxyParams.BasicAuthentication := False;
- IdHTTP.ProxyParams.ProxyPort := 0;
- IdHTTP.Request.ContentLength := -1;
- IdHTTP.Request.ContentRangeEnd := 0;
- IdHTTP.Request.ContentRangeStart := 0;
- IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
- IdHTTP.Request.Accept := 'text/html, */*';
- IdHTTP.Request.BasicAuthentication := False;
- IdHTTP.Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)';
- IdHTTP.HTTPOptions := [hoForceEncodeParams];
- RequestURL := 'http://ip.taobao.com/service/getIpInfo.php?ip=' + edtIP.Text;
- ResponseStream := TStringStream.Create;
- IdHTTP.Get(RequestURL, ResponseStream);
- IdHTTP.Free;
- ResponseStream.Position := 0;
- Memo1.Text := ResponseStream.DataString;
- ResponseStream.Position := 0;
- JO := TJSONObject.ParseJSONValue(ResponseStream.DataString) as TJSONObject;
- JData := JO.Get('data').JsonValue as TJSONObject;
- leISP.Text := (JData.Get('isp').JsonValue as TJSONString).Value;
- leCountry.Text := (JData.Get('country').JsonValue as TJSONString).Value;
- leArea.Text := (JData.Get('area').JsonValue as TJSONString).Value;
- leRegion.Text := (JData.Get('region').JsonValue as TJSONString).Value;
- leCity.Text := (JData.Get('city').JsonValue as TJSONString).Value;
- JO.Free;
- ResponseStream.Free;
- end;
源代码下载:http://www.400gb.com/file/63073750
Delphi使用JSON解析调用淘宝IP地址库REST API 示例的更多相关文章
- Jsp调用淘宝IP地址库获取来访IP详细信息
Jsp调用淘宝IP地址库获取来访IP详细信息 示例网页点击:www.trembler.cn/ipinfo/ipinfo(服务器有其他用处,页面已失效) String ip = request.ge ...
- WordPress使用淘宝IP地址库的API显示评论者的位置信息(二)
1 淘宝IP地址库的接口说明 在上一篇文章<WordPress使用淘宝IP地址库的API显示评论者的位置信息(一)>中,vfhky使用了新浪工具提供的这个IP接口显示博客评论者的位置信息. ...
- 用淘宝ip地址库查ip
这是一个通过调用淘宝ip地址库实现ip地址查询的功能类 using System; using System.Collections.Generic; using System.Linq; using ...
- 淘宝IP地址库采集器c#代码
这篇文章主要介绍了淘宝IP地址库采集器c#代码,有需要的朋友可以参考一下. 最近做一个项目,功能类似于CNZZ站长统计功能,要求显示Ip所在的省份市区/提供商等信息.网上的Ip纯真数据库,下载下来一看 ...
- 淘宝IP地址库采集器c#
个人原创.欢迎转载.转载请注明出处.http://www.cnblogs.com/zetee/articles/3482085.html 采集器概貌,如下: 最近做一个项目,功能类似于CNZZ站长统计 ...
- 免费淘宝IP地址库简介及PHP/C#调用实例
https://yq.aliyun.com/ziliao/25800?spm=a2c4e.11155472.0.0.68027abfcpFb7O 摘要: 本文讲的是免费淘宝IP地址库简介及PHP/C# ...
- 淘宝IP地址库采集
作者:阿宝 更新:2016-08-31 来源:彩色世界(https://blog.hz601.org/2016/08/31/taobao-ip-sniffer/index.html) 简述 当初选择做 ...
- 淘宝IP地址库API接口(PHP)通过ip获取地址信息
淘宝IP地址库网址:http://ip.taobao.com/ 提供的服务包括: 1. 根据用户提供的IP地址,快速查询出该IP地址所在的地理信息和地理相关的信息,包括国家.省.市和运营商. 2. 用 ...
- 淘宝IP地址库API地址
淘宝IP地址库:http://ip.taobao.com/instructions.php 接口说明 1. 请求接口(GET): http://ip.taobao.com/service/getI ...
随机推荐
- oracle merge into 语法
MERGE INTO upperLowerLimitData t1 USING (select name,enname,starttime,value ... from dual) t2 ON ( ...
- [原创汉化]linux前端神器 WebStorm8 汉化
只汉化了linux版本 因为linux的工具没win多 不过汉化应该都通用的,自行尝试下. 汉化的不是很完全.有时间放出完全版本来.汉化是个体力活 转载随易,汉化不易,且转且注明 截图: http:/ ...
- IntelliJ IDEA 15 显示工具栏及底部周边工具栏
- MyEclipse2015破解版_MyEclipse 2015 stable 2.0 稳定版 破解日志
前言:在MyEclipse 2015 Stable 1.0下载安装破解日志(http://www.cnblogs.com/wql025/p/5161979.html)一文中,笔者主要讲述了该版本的破解 ...
- log4j安装与简介
问题描述: 在应用程序中添加日志记录总的来说基于三个目的: (1) 监视代码中变量的变化情况,周期性的记录到文件中供其他应用进行统计分析工作: (2) 跟踪代码运行时轨迹,作为日 ...
- Spring3+hibernate4+struts2整合的 过程中发生如下错误
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderLis ...
- Introduction To Monte Carlo Methods
Introduction To Monte Carlo Methods I’m going to keep this tutorial light on math, because the goal ...
- 宏基5750G 不能用内置无线网卡上网
宏基5750G 不能用内置无线网卡上网 具体体现在: 1.--> 搜索不到无线网络: 2.点击“打开网络和共享中心”-->没有“管理无线网络”一项.如果正常的话应该是这样的: 3.“我的电 ...
- HTTP请求报文与响应报文
http://docs.telerik.com/fiddler/KnowledgeBase/HTTP HTTP请求报文与响应报文 HTTP http://www.w3.org/Protocols/rf ...
- Unity3D WP8发布解决方案名 DefaultPackageName 修改问题
原地址:http://blog.csdn.net/w337198302/article/details/16960661 在对Unity3D游戏进行Windows phone 8 发布的时候,首先是需 ...