• 新浪检查前端机脚本


     1 #!/usr/bin/python
     2 import urllib2
     3 
     4 server_list = []
     5 product_list = ['/dpool/hdpic/index.php']
     6 
     7 def main():
     8     for ip in server_list:
     9         for product in product_list:
    10             url = 'http://%s%s' % (ip, product)
    11             request = urllib2.Request(url)
    12             request.add_header('Host', 'dp.sina.cn');
    13             try:
    14                 response = urllib2.urlopen(request)
    15                 print url
    16             except urllib2.HTTPError, e:
    17                 print "Code:%s Msg:%s Url:%s Ip:%s" % (e.code, e.reason, url, ip)
    18         
    19 if __name__ == '__main__':
    20     main()

    在日常维护过程中经常要检查负责的产品页面情况,随时有新上线的前端机要我们测试,所以诞生了此工具脚本,Like Python

    MD优化了一下

    #!/usr/bin/python
    import urllib2
    import os
    import re
    
    server_list = []
    lines = os.popen('host ******* | sort').readlines()
    for line in lines:
        s = re.search('(\.?\d+){4}', line)
        if s:
            server_list.append(s.group())
    
    product_list = ['/dpool/hdpic/index.php']
    
    def main():
        for ip in server_list:
            for product in product_list:
                url = 'http://%s%s' % (ip, product)
                request = urllib2.Request(url)
                request.add_header('Host', 'dp.sina.cn');
                try:
                    response = urllib2.urlopen(request)
                    print url
                except urllib2.HTTPError, e:
                    print "Code:%s Msg:%s Url:%s Ip:%s" % (e.code, e.reason, url, ip)
                except urllib2.URLError, e:
                    print "Code:%s Msg:%s Url:%s Ip:%s" % (e.code, e.reason, url, ip)
            
    if __name__ == '__main__':
        main()
  • 相关阅读:
    Ellipse4SL 的安装包和环境配置要求
    什么是SOHO人
    D2上的Silverlight
    银光团队项目正式启动,欢迎您的参与!
    Silverlight开发团队招募SOHO团员若干
    SOHO新的生活方式
    [银客北京开发团队]承接各种Silverlight和WPF外包项目和合作项目
    微软Silverlight 3.0 概观
    grers
    翻译电文
  • 原文地址:https://www.cnblogs.com/aboys/p/3105707.html
Copyright © 2020-2023  润新知