Python简单获取自身外网IP的方法
作者:RQSLT 时间:2023-12-26 03:44:31
本文实例讲述了Python简单获取自身外网IP的方法。分享给大家供大家参考,具体如下:
#encoding=utf-8
#author: walker
#date: 2016-03-07
#function: 获取自己的外网IP
import requests
from bs4 import BeautifulSoup
#获取外网IP
def GetOuterIP():
url = r'http://www.whereismyip.com/'
r = requests.get(url)
bTag = BeautifulSoup(r.text, 'html.parser', from_encoding='utf-8').find('b')
ip = ''.join(bTag.stripped_strings)
print('ip:' + ip)
if __name__ == '__main__':
GetOuterIP()
希望本文所述对大家Python程序设计有所帮助。
标签:Python,外网IP
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python怎么提高计算速度
2021-06-09 17:04:42
详解Python结合Genetic Algorithm算法破解网易易盾拼图验证
2023-05-22 01:34:36
![](https://img.aspxhome.com/file/2023/6/89046_0s.png)
JavaScript 中的 setAttribute
2008-08-18 13:08:00
在Python程序员面试中被问的最多的10道题
2022-02-27 08:20:03
如何用Python一次性下载抖音上音乐
2022-10-31 04:14:09
![](https://img.aspxhome.com/file/2023/2/67412_0s.jpg)
vue2.0+vue-dplayer实现hls播放的示例
2024-05-29 22:46:56
![](https://img.aspxhome.com/file/2023/2/123002_0s.png)
深入讲解SQL中的字符串拼接
2024-01-23 17:52:00
![](https://img.aspxhome.com/file/2023/9/102059_0s.png)
Python实现同时兼容老版和新版Socket协议的一个简单WebSocket服务器
2023-05-21 10:05:28
用Python爬取某乎手机APP数据
2021-02-03 17:04:59
![](https://img.aspxhome.com/file/2023/3/118503_0s.png)
python argparse传入布尔参数false不生效的解决
2023-07-03 16:12:20
oracle远程连接服务器数据库图文教程
2023-07-12 22:22:37
![](https://img.aspxhome.com/file/2023/0/64440_0s.png)
微信小程序开发注意指南和优化实践(小结)
2024-04-17 10:38:05
![](https://img.aspxhome.com/file/2023/7/136217_0s.jpg)
mssql2005,2008导出数据字典实现方法
2023-07-23 19:11:30
Python直接赋值、浅拷贝与深度拷贝实例分析
2023-03-15 08:08:02
![](https://img.aspxhome.com/file/2023/9/126989_0s.png)
python求解三角形第三边长实例
2021-08-24 06:16:28
![](https://img.aspxhome.com/file/2023/8/95398_0s.png)
小程序登录/注册页面设计的实现代码
2024-04-18 09:44:10
![](https://img.aspxhome.com/file/2023/6/136286_0s.png)
Django利用AJAX技术实现博文实时搜索
2023-01-02 01:57:50
![](https://img.aspxhome.com/file/2023/3/80583_0s.jpg)
有关将idea的系统配置文件移到其它盘激活失效的问题
2022-02-16 09:33:37
SqlServer数据库远程连接案例教程
2024-01-21 10:16:08
![](https://img.aspxhome.com/file/2023/8/99988_0s.png)
asp如何使用MsChart制图工具?
2010-06-05 12:40:00