我想检查我的 ip 服务器是否打开或没有用于项目但是使用 python 有人可以帮助我吗?
See below code - paste the UrL link which you want to check if status code is 200 it is accessible else not accessible means site is down .
import requests
page = requests.get('https://en.wikipedia.org/wiki/Akki')
if page.status_code==200:
print("Server is up ")
else:
print("Server is down")
Please try this
import os
my_hostname='142.251.40.206'
ip_UP = True if os.system("ping -c 1 " + my_hostname) == 0 else False
print(ip_UP)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.