简单的域名备案查询

# -*- coding: utf-8 -*-
#jk409于2014-5-5用python3.4编写用以查询域名的备案状态
def chaxun():
    import urllib.request
    domain_s='http://api.k780.com:88/?app=domain.beian&domain='
    domain_end='&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json'
    #domain_j=str(input("请输入需要查询的域名:"))
    domain=domain_s+domain_j+domain_end
    res=urllib.request.urlopen(domain)
    for pages in res:
        page=eval(pages)
    if page["success"] == "0":
        print("=========================================")
        print("网站域名:",domain_j)
        print("备案状态:","数据出错 或 未备案!")
        print("=========================================\n")
        #page=page.decode("utf8")
    else:
        #for pagea in page["result"]:
         #print (pagea+'\t\t'+page["result"][pagea])
        print("=========================================")
        print("网站域名:",page["result"]["domain"])
        print("备案状态:","已备案")
        print("网站备案:",page["result"]["icpno"])
        print("首页地址:",page["result"]["webhome"])
        print("主办单位:",page["result"]["organizers"])
        print("单位性质:",page["result"]["organizers_type"])
        print("审核时间:",page["result"]["exadate"])
        print("=========================================\n")
if __name__=="__main__":
    while 1:
        domain_j=str(input("请输入需要查询的域名:"))
        if domain_j == "quit":
            break
        chaxun()


你可能感兴趣的:(python,备案查询)