`
crackajack_zg
  • 浏览: 52945 次
社区版块
存档分类
最新评论

python 模仿web页面检测域名是否被注册

 
阅读更多
最近在给朋友弄个网站,网站基本弄好以后就要申请个域名,以前也接触过域名注册的,这次想真个拉风点的域名,结果。。。令人大失所望。
在不断重复的提交后,发现可以弄个程序检测一下有没有好点的域名,这样就不用人为输入域名了。然后就有了 下面的代码。

#!/bin/env python
#coding=gbk
import urllib
import urllib2
import time

'''关键字构造'''
def analysis(radix,keyword,lenSize):
    global res_f
    global res_e
    if radix==10:
        if keyword<radix:
            res_f.append(keyword)
        else:
            res_f.append(keyword%radix)
            analysis(radix,keyword/radix,lenSize)
    else:
        if keyword<radix:
            res_e.append(keyword)
        else:
            res_e.append(keyword%radix)
            analysis(radix,keyword/radix,lenSize)
'''form表单提交的地址,不好意思啊请求了几十万次'''
url = 'http://www.7data.com/domain_reg/'
'''域名中字符串的长度'''
chars_length = 3
'''域名中数字的长度'''
numbers_length = 1

print('auto check begin')
total_chars = 26**chars_length
total_numbers = 10**numbers_length
total_index = total_numbers*total_chars

i = 7
j = 26*26*11
'''这层循环是 对数字的遍历'''
while i<=7:
    res_f=[]
    analysis(10,i,numbers_length)
    domain_f = ''

    c = numbers_length-len(res_f)
    index_1 = 0
    '''这层循环是对英文字母的遍历'''
    while index_1<c:
        res_f.insert(len(res_f), 0)
        index_1=index_1+1
            
            
    for res_f_str in res_f:
        domain_f=str(res_f_str)+domain_f
        #print (domain_f)

    while j<=total_chars:
        res_e=[]
        analysis(26,j,chars_length)
        index_2 = 0
        c2 = chars_length-len(res_e)
        while index_2<c2:
            res_e.insert(len(res_e), 0)
            index_2=index_2+1
        domain_e = ''
        #print res_e
        for res_e_str in res_e:
            domain_e = chr(res_e_str+97)+domain_e
        #print (j,':',domain_e)
        '''要注册的域名'''
        domainname=domain_e+domain_f
        #domainname=domain_e
        time.sleep(0.1)
        values = {'module':'domainsearch','vrf':'','searchType':'IntDomain','action':'check','searchedDomainName':domainname,'suffix':'.com','imageField2.x':'41','imageField2.y':'17'}
        data = urllib.urlencode(values)
        req = urllib2.Request(url, data)
        try:
            #response=''
            response = urllib2.urlopen(req)
        except Exception,e:
            print (Exception,'domain:',domainname,e)
        
            
        hasResistflag = True
        '''判断是否成功'''
        for line in response:
            if line.find('yes.jpg')>0:
                hasResistflag=False
                break
    
        if not hasResistflag:
            print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())),'index:',j,'domains:',domainname,' --------------can regist--------------')
        else:
            print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())),'index:',j,'domains:',domainname,' can not regist')
            
            
        j=j+1
    i=i+1

print('auto check end')

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics