My first Python program(Domains ICP record query based on API)

Demo

Explain

This is my first work after learning python . It's a domains ICP record query based on API .

API provider : http://api.btstu.cn

This code is not perfect, there is still room for improvement , For example, the code only shows the successful parts of domains ICP record, but not the unsuccessful parts

Dome Code

# 基于API实现的域名备案查询
# 模块
import requests
import json


# Get_API
'''
返回格式
{"code":"200"
"主办单位名称":"深圳市腾讯计算机系统有限公司"
"主办单位性质":"企业"
"网站备案/许可证号":"粤B2-20090059-5"
"网站名称":"腾讯网"
"网站首页网址":"qq.com"
"审核时间":"2020-10-27"}  
'''

# Start
url = input("请输入待查询地址:")    # 获得查询地址

# API地址
break_api = requests.get("http://api.btstu.cn/icp/api.php?domain=" + url)

# 解析返回Json
break_api = break_api.text
break_api_dic = json.loads(break_api)   # 转换为字典

# 打印结果
print(
    "返回状态:" + break_api_dic["code"] + "\n"
    "主办单位名称:" + break_api_dic["主办单位名称"] + "\n"
    "主办单位性质:" + break_api_dic["主办单位性质"] + "\n"
    "网站备案/许可证号:" + break_api_dic["网站备案/许可证号"] + "\n"
    "网站名称:" + break_api_dic["网站名称"] + "\n"
    "网站首页网址:" + break_api_dic["网站首页网址"] + "\n"
    "审核时间:" + break_api_dic["审核时间"]

)

# end
阅读剩余
THE END