Python如何抓取淘宝IP地址数据
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,这篇文章主要介绍Python如何抓取淘宝IP地址数据,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!示例代码def fetch(ip): url = 'http://ip.
千家信息网最后更新 2025年12月02日Python如何抓取淘宝IP地址数据
这篇文章主要介绍Python如何抓取淘宝IP地址数据,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
示例代码
def fetch(ip): url = 'http://ip.taobao.com/service/getIpInfo.php?ip=' + ip result = [] try: response = urllib.urlopen(url).read() jsondata = json.loads(response) if jsondata[u'code'] == 0: result.append(jsondata[u'data'][u'ip'].encode('utf-8')) result.append(jsondata[u'data'][u'country'].encode('utf-8')) result.append(jsondata[u'data'][u'country_id'].encode('utf-8')) result.append(jsondata[u'data'][u'area'].encode('utf-8')) result.append(jsondata[u'data'][u'area_id'].encode('utf-8')) result.append(jsondata[u'data'][u'region'].encode('utf-8')) result.append(jsondata[u'data'][u'region_id'].encode('utf-8')) result.append(jsondata[u'data'][u'city'].encode('utf-8')) result.append(jsondata[u'data'][u'city_id'].encode('utf-8')) result.append(jsondata[u'data'][u'county'].encode('utf-8')) result.append(jsondata[u'data'][u'county_id'].encode('utf-8')) result.append(jsondata[u'data'][u'isp'].encode('utf-8')) result.append(jsondata[u'data'][u'isp_id'].encode('utf-8')) else: return 0, result except: logging.exception("Url open failed:" + url) return 0, result return 1, result def worker(ratelimit, jobs, results, progress): global cancel while not cancel: try: ratelimit.ratecontrol() ip = jobs.get(timeout=2) # Wait 2 seconds ok, result = fetch(ip) if not ok: logging.error("Fetch information failed, ip:{}".format(ip)) progress.put("") # Notify the progress even it failed elif result is not None: results.put(" ".join(result)) jobs.task_done() # Notify one item except Queue.Empty: pass except: logging.exception("Unknown Error!")def process(target, results, progress): global cancel while not cancel: try: line = results.get(timeout=5) except Queue.Empty: pass else: print >>target, line progress.put("") results.task_done()def progproc(progressbar, count, progress): """ Since ProgressBar is not a thread-safe class, we use a Queue to do the counting job, like two other threads. Use this thread do the printing of progress bar. By the way, it will print to stderr, which does not conflict with the default result output(stdout). """ idx = 1 while True: try: progress.get(timeout=5) except Queue.Empty: pass else: progressbar.update(idx) idx += 1
以上是"Python如何抓取淘宝IP地址数据"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!
地址
数据
淘宝
内容
篇文章
代码
价值
兴趣
小伙
小伙伴
更多
知识
示例
行业
资讯
资讯频道
频道
参考
帮助
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
法国对外安全总局网络安全
如何把pdf放到服务器
网卡能玩我的世界服务器吗
一个服务器两个网卡怎么用
大兴区综合软件开发
丹霞旭日服务器
网络安全保卫局是几局
软件开发会干什么
软件开发调研途径有那些
广州注册软件开发公司
网络安全实验室本关
怀旧服最新各服务器人数
网络技术和以太网
z9x无法连接到服务器
数据库英超
无线网络技术课程
易销互联网科技
机柜服务器维修公司
网络安全 key或ctf值
氨基磺酸数据库
给视频加字幕的手机软件开发
云计算机服务器的价格对比
各大银行的软件开发中心
起点服务器炸了吗2022
html5 服务器
exl导入erp数据库数据
什么语言可以创建sql数据库
如何查看本地服务器的数据备份
维护网络安全的重要手段
上海恺擎软件开发有限公司