国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python3實現域名查詢和whois查詢功能

2020-02-15 21:57:43
字體:
來源:轉載
供稿:網友

1. 域名查詢

萬網提供了域名查詢接口,接口采用HTTP協議:

接口URL:http://panda.www.net.cn/cgi-bin/check.cgi

接口參數:area_domain,接口參數值為標準域名,例:doucube.com

調用舉例:

http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=doucube.com

返回:

<?xml version="1.0" encoding="gb2312" ?> - <property> <returncode>200</returncode>  <key>doucube.com</key>  <original>211 : Domain name is not available</original>  </property>

返回結果說明:

<returncode>200</returncode> 返回碼,200表示返回成功<key>doucube.com</key> 表示當前查詢的域名<original>211 : Domain name is not available</original> 返回結果的原始信息,主要有以下幾種original=210 : Domain name is available  表示域名可以注冊original=211 : Domain name is not available 表示域名已經注冊original=212 : Domain name is invalid  表示查詢的域名無效original=213 : Time out 查詢超時

用python3實現如下

1.1 查詢已經被注冊的域名

import urllib.requestreq = urllib.request.urlopen('http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=doucube.com')print(req.read().decode())

返回結果:不可用,已經被注冊

<?xml version="1.0" encoding="gb2312" ?> - <property> <returncode>200</returncode>  <key>doucube.com</key>  <original>211 : Domain name is not available</original>  </property>

1.2 查詢沒有被注冊的域名

req2 = urllib.request.urlopen('http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=doucube.net')
print(req2.read().decode())

返回結果:可用,未被注冊

 <?xml version="1.0" encoding="gb2312" ?> - <property> <returncode>200</returncode>  <key>doucube.net</key>  <original>210 : Domain name is available</original>  </property>

1.3 查詢不存在的域名,使用不存在的后綴

req3 = urllib.request.urlopen('http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=doucube.net2')
print(req3.read().decode())

返回結果:域名無效

 <?xml version="1.0" encoding="gb2312" ?> - <property> <returncode>200</returncode>  <key>doucube.net2</key>  <original>212 : Domain name is invalid</original>  </property>

.whois查詢

由于沒有找到像域名查詢接口那樣好的API,這里直接抓取站長之家的whois查詢頁面(http://whois.chinaz.com/)

req_whois = urllib.request.urlopen('http://whois.chinaz.com/doucube.com')print(req_whois.read().decode())            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 威宁| 徐闻县| 郑州市| 南京市| 德钦县| 娄底市| 东乡县| 裕民县| 东台市| 沈丘县| 三门县| 普陀区| 呼玛县| 江西省| 龙岩市| 轮台县| 和政县| 盐山县| 施秉县| 咸阳市| 遂溪县| 宝鸡市| 密云县| 扬中市| 基隆市| 磐石市| 乌拉特前旗| 兴和县| 屯留县| 平定县| 阿图什市| 大关县| 清涧县| 岱山县| 伊金霍洛旗| 绥化市| 黔东| 剑川县| 香河县| 宝山区| 梨树县|