域名过期提前预警脚本
【摘要】 #!/root/.virtualenvs/script/bin/python
#coding=utf-8
import re
import time, mechanize
import urllib2
import random
URL = 'http://whois.chinaz.com/'
def str_cut(str,startsep,endsep...
#!/root/.virtualenvs/script/bin/python
#coding=utf-8
import re
import time, mechanize
import urllib2
import random
URL = 'http://whois.chinaz.com/'
def str_cut(str,startsep,endsep): str1=str.split(startsep)[1] str2=str1.split(endsep)[0] return str2
br = mechanize.Browser()
br.set_handle_equiv(True)
br.set_handle_gzip(False)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(True)
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
#br.set_debug_http(True)
#br.set_debug_redirects(True)
#br.set_debug_responses(True)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.
1')]
domain_list = [你的域名列表]
r = br.open(URL)
for index, item in enumerate(domain_list): try: br.select_form(nr=0) br.form['DomainName'] = item br.submit() contents = br.response().read() if contents.find('<div id="whoisinfo" class="div_whois">')==-1: print item + " " + "not found" else: contents=str_cut(contents,'<div id="whoisinfo" class="div_whois">','</div>') contents=contents.replace('<br/>',',')[:-1] a = re.split(',',contents) for i in a: m = re.match(r"过期时间", i) if m: print '域名 : %s, 过期时间 : %s' % (item, re.sub(r"年|月", '-', i[15:-3]).strip()[:10]) br.back() except Exception,e: print Exception,":",e time.sleep(1.27*random.randint(4, 12))
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
文章来源: zmedu.blog.csdn.net,作者:互联网老辛,版权归原作者所有,如需转载,请联系作者。
原文链接:zmedu.blog.csdn.net/article/details/73440818
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)