爬虫实例3——获取指定IP地址的物理位置
2015-06-23 10:34
330 查看
# -*- coding: utf-8 -*- import requests import json def get_physical_location(ip): url = 'http://ip.taobao.com/service/getIpInfo.php?ip=' + ip ip_data = requests.get(url).text ip_dict = json.loads(ip_data) if ip_dict.get('code'): print('你输入的ip地址格式有误,请仔细检查。') else: country = ip_dict.get('data').get('country') region = ip_dict.get('data').get('region') city = ip_dict.get('data').get('city') return country + region + city if __name__ == '__main__': print get_physical_location('8.8.8.8')
相关文章推荐
- Python3写爬虫(四)多线程实现数据爬取
- Scrapy的架构介绍
- 房产界已上市和IPO路上的难兄难弟:房天下与房多多
- 雷军是谁,他为什么而奋斗?小米上市和雷军的英雄主义
- IP网络路由技术
- 如何利用“IP地址欺骗”
- 新手看招:避免网络 IP 地址被非法修改
- 网络管理之IP地址篇
- ip地址基础知识
- 脚本之家因服务器资源紧张 换了ip并升级了带宽
- IP地址组成与类型
- 计算机名DNS网关IP(大家可以用来学习)
- 一个能对访问者进行编号、记录访问次数、IP、时间的统计制作实例
- 用vbscript脚本实现返回 IP 配置数据的代码
- 用vbs针对一个 IP 地址范围运行脚本
- asp实现检查ip地址是否为内网或者私有ip地址的代码分享
- 根据IP跳转到用户所在城市的实现步骤
- vbs版IP地理位置查询小偷
- bat脚本显示本机IP地址的两种方法(内网ip)