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

首頁 > 編程 > Python > 正文

Python批量查詢域名是否被注冊過

2020-01-04 16:53:02
字體:
供稿:網(wǎng)友

step1. 找一個單詞數(shù)據(jù)庫

這里有一個13萬個單詞的

http://download.csdn.net/detail/u011004567/9675906

新建個mysql數(shù)據(jù)庫words,導(dǎo)入words里面就行

step2.找個查詢接口

這里我用的是http://apistore.baidu.com/astore/serviceinfo/27586.html

step3. 執(zhí)行Python腳本

# -*- coding: utf-8 -*-'''域名注冊查詢'''__author__ = 'Jimmy'from sqlalchemy import Column, String,Integer, create_enginefrom sqlalchemy.orm import sessionmakerfrom sqlalchemy.ext.declarative import declarative_baseimport requestsimport jsonfrom html.parser import HTMLParserrequest_failure = []domain_available = []def writeToText(list,fn):  file = open(fn, 'w')  file.write(str(list))  file.close()class bodyJSON(HTMLParser):  tag = False  def handle_starttag(self, tag, attr):    if tag == 'body':      self.tag = True  def handle_endtag(self, tag):    if tag == 'body':      self.tag = False  def handle_data(self, data):    if self.tag:      self.data = data  def getJSON(self):    return self.dataBase = declarative_base()class Words(Base):  # 表的名字:  __tablename__ = 'words'  # 表的結(jié)構(gòu):  ID = Column(Integer(), primary_key=True)  word = Column(String(100))  exchange = Column(String(1000))  voice = Column(String(1000))  times = Column(Integer())# 初始化數(shù)據(jù)庫連接:engine = create_engine('mysql+mysqlconnector://root:846880@localhost:3306/words')# 創(chuàng)建DBSession類型:DBSession = sessionmaker(bind=engine)# 創(chuàng)建Session:session = DBSession()# 創(chuàng)建Query查詢,filter是where條件,最后調(diào)用one()返回唯一行,如果調(diào)用all()則返回所有行:words = session.query(Words).filter(Words.ID).all()def searchInaaw8(words):  length = len(words)  print('====開始搜索...=====共%d個單詞' %length)  for i in range(0,length):    word = words[i]    url = 'http://www.aaw8.com/Api/DomainApi.aspx?domain=%s.com' % word.word    r = requests.get(url)    if r.status_code == 200:      if r.headers['Content-Type'] == 'text/html':        print('第%s個請求被拒絕,url = %s' % (i, url))      else:        body = bodyJSON()        body.feed(r.text)        res = json.loads(body.getJSON())        if res['StateID'] == 210:          print('第%d次,%s.com 未被注冊' % (i, word.word))          domain_available.append(word.word)        elif res['StateID'] == 0:          print('第%d次,%s.com 查詢接口出錯' % (i, word.word))          request_failure.append(word.word)        elif res['StateID'] == 211:          pass          print('第%d次,%s.com 已經(jīng)被注冊' % (i, word.word))        elif res['StateID'] == 213:          print('第%d次,%s.com 查詢超時' % (i, word.word))          request_failure.append(word.word)        else:          print('其他錯誤')          request_failure.append(word.word)        body.close()    else:      print('請求失敗')      request_failure.append(word.word)  print('查詢結(jié)束...')  print('查詢失敗:')  print(request_failure)  writeToText(request_failure,'failure.text')  print('未注冊域名:')  print(domain_available)  writeToText(request_failure,'available.text')searchInaaw8(words)

step4:放到阿里云就可以搞事情啦

python,查詢,域名,是否注冊過

以上所述是小編給大家介紹的Python批量查詢域名是否被注冊過,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對VEVB武林網(wǎng)網(wǎng)站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 陆川县| 武邑县| 苍南县| 扎赉特旗| 新巴尔虎左旗| 固阳县| 楚雄市| 汕尾市| 宜州市| 五常市| 阿瓦提县| 建湖县| 连江县| 广安市| 方正县| 万全县| 苏尼特右旗| 上思县| 霍城县| 彩票| 昔阳县| 托克逊县| 博爱县| 苏州市| 托克逊县| 枣强县| 西畴县| 新蔡县| 泸水县| 织金县| 长顺县| 宽甸| 新和县| 黎川县| 巴东县| 抚松县| 林周县| 天等县| 昭觉县| 木兰县| 乌拉特前旗|