十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Python 脚本如下:
测试淘宝的ip库,拿到的数据内容如下:
http://ip.taobao.com/service/getIpInfo.php?ip=66.249.65.183
获取到的字典在http://tool.oschina.net/codeformat/json 进行格式化得到下面格式{ "code": 0, "data": { "country": "中国", "country_id": "CN", "area": "华南", "area_id": "800000", "region": "广东省", "region_id": "440000", "city": "深圳市", "city_id": "440300", "county": "", "county_id": "-1", "isp": "电信", "isp_id": "100017", "ip": "113.97.193.87" }}
数据数据库语句:
mysql> create database intest ; Query OK, 1 row affected (0.00 sec) mysql> use intest; Database changed mysql> create table ipinfo(id int auto_increment primary key,ipaddress varchar(200),countip int); Query OK, 0 rows affected (0.22 sec) mysql> create table whereip(id int primary key auto_increment,country varchar(100),area varchar(100),region varchar(100),city varchar(100),ip varchar(100),time datetime); Query OK, 0 rows affected (0.20 sec) mysql> mysql> desc ipinfo; +-----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | ipaddress | varchar(200) | YES | | NULL | | | countip | int(11) | YES | | NULL | | +-----------+--------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec) mysql> desc whereip; +---------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | country | varchar(100) | YES | | NULL | | | area | varchar(100) | YES | | NULL | | | region | varchar(100) | YES | | NULL | | | city | varchar(100) | YES | | NULL | | | ip | varchar(100) | YES | | NULL | | | time | datetime | YES | | NULL | | +---------+--------------+------+-----+---------+----------------+ 7 rows in set (0.00 sec) mysql>分析完日志查看数据库的内容:
mysql> select * from whereip limit 10; +----+---------+--------+-----------+-----------+-----------------+---------------------+ | id | country | area | region | city | ip | time | +----+---------+--------+-----------+-----------+-----------------+---------------------+ | 1 | 美国 | | | | 66.249.65.133 | 2016-09-01 10:53:01 | | 2 | 美国 | | | | 23.251.63.45 | 2016-09-01 10:53:01 | | 3 | 美国 | | | | 23.251.63.45 | 2016-09-01 10:53:01 | | 4 | 中国 | 华南 | 广东省 | 广州市 | 119.130.71.153 | 2016-09-01 10:53:01 | | 5 | 美国 | | | | 66.249.65.183 | 2016-09-01 10:53:01 | | 6 | 美国 | | | | 66.249.65.180 | 2016-09-01 10:53:01 | | 7 | 美国 | | | | 66.249.65.142 | 2016-09-01 10:53:01 | | 8 | 美国 | | | | 107.151.226.203 | 2016-09-01 10:53:01 | | 9 | 美国 | | | | 107.151.226.203 | 2016-09-01 10:53:01 | | 10 | 美国 | | | | 66.249.65.134 | 2016-09-01 10:53:01 | +----+---------+--------+-----------+-----------+-----------------+---------------------+ 10 rows in set (0.00 sec) mysql>另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。