zoukankan      html  css  js  c++  java
  • 获取href 属性值

    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import urllib2
    import urllib
    import cookielib
    import json
    import httplib
    import re
    import requests
    from lxml import etree
    import StringIO
    import time
    s = requests.session()
    print s.headers
    url = "http://x.x.26.8:8760/"
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0'
    }
    r = s.get(url, timeout=10, headers=headers)
    r=r.text
    r=r.encode('utf8')
    print type(r)
    f=open('fh1.html','w')
    f.write(r)
    f.close()
    fh1=open('fh1.html','r')
    fh2=fh1.read()
    #print fh2
    htmlEmt=etree.HTML(fh2)
    #<a href="http://x.x.200.17:7003/loan-web/4ALogon.jsp?tgt=TGT-130672-O1fcAq4HGXFxYjmzfMfuIxAFlqgOfEzNVXja1fDMm5C7IXb7Ox-cas01.example.org" target="_blank">信贷系统</a>
    #根据a标签,获取href的值
    result=htmlEmt.xpath('//a/@href')
    print result
    # print type(result)
    # print len(result)
    for x in result:
        #print  x
        a=re.search('http://d+.d+.d+.d+',x)
        if a:
           print x
           #print type(a)
    fh1.close()
    
    
    C:Python27python.exe C:/Users/tlcb/PycharmProjects/untitled/httprequest/gj.py
    {'Connection': 'keep-alive', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'User-Agent': 'python-requests/2.18.4'}
    <type 'str'>
    ['', '', '/lastn', 'http://x.x.26.8:8761/eureka/', 'http://x.x.26.9:8760/eureka/', 'http://x.x.26.2:7006/actuator/info', 'http://x.x.26.1:7006/actuator/info', 'http://x.x.26.2:7009/actuator/info', 'http://x.x.26.1:7009/actuator/info', 'http://x.x.26.1:7007/actuator/info', 'http://x.x.26.2:7007/actuator/info', 'http://x.x.26.2:7008/actuator/info', 'http://x.x.26.1:7008/actuator/info', 'http://x.x.26.1:7002/actuator/info', 'http://x.x.26.2:7002/actuator/info', 'http://x.x.26.1:7003/actuator/info', 'http://x.x.26.2:7003/actuator/info', 'http://x.x.26.1:7004/actuator/info', 'http://x.x.26.2:7004/actuator/info', 'http://x.x.26.1:7005/actuator/info', 'http://x.x.26.2:7010/actuator/info', 'http://x.x.26.1:7010/actuator/info', 'http://x.x.26.2:7005/actuator/info', 'http://x.x.26.2:8020/actuator/info', 'http://x.x.26.1:8020/actuator/info', 'http://x.x.26.4:8082/actuator/info', 'http://x.x.26.3:8082/actuator/info', 'http://x.x.26.4:8085/actuator/info', 'http://x.x.26.3:8085/actuator/info', 'http://x.x.26.4:8086/actuator/info', 'http://x.x.26.3:8086/actuator/info', 'http://x.x.26.3:8089/actuator/info', 'http://x.x.26.4:8089/actuator/info', 'http://x.x.26.4:8087/actuator/info', 'http://x.x.26.3:8087/actuator/info', 'http://ebillspub2:9999/actuator/info', 'http://ebillspub1:9999/actuator/info', 'http://x.x.26.9:8086/actuator/info', 'http://x.x.26.8:8086/actuator/info']
    http://x.x.26.8:8761/eureka/
    http://x.x.26.9:8760/eureka/
    http://x.x.26.2:7006/actuator/info
    http://x.x.26.1:7006/actuator/info
    http://x.x.26.2:7009/actuator/info
    http://x.x.26.1:7009/actuator/info
    http://x.x.26.1:7007/actuator/info
    http://x.x.26.2:7007/actuator/info
    http://x.x.26.2:7008/actuator/info
    http://x.x.26.1:7008/actuator/info
    http://x.x.26.1:7002/actuator/info
    http://x.x.26.2:7002/actuator/info
    http://x.x.26.1:7003/actuator/info
    http://x.x.26.2:7003/actuator/info
    http://x.x.26.1:7004/actuator/info
    http://x.x.26.2:7004/actuator/info
    http://x.x.26.1:7005/actuator/info
    http://x.x.26.2:7010/actuator/info
    http://x.x.26.1:7010/actuator/info
    http://x.x.26.2:7005/actuator/info
    http://x.x.26.2:8020/actuator/info
    http://x.x.26.1:8020/actuator/info
    http://x.x.26.4:8082/actuator/info
    http://x.x.26.3:8082/actuator/info
    http://x.x.26.4:8085/actuator/info
    http://x.x.26.3:8085/actuator/info
    http://x.x.26.4:8086/actuator/info
    http://x.x.26.3:8086/actuator/info
    http://x.x.26.3:8089/actuator/info
    http://x.x.26.4:8089/actuator/info
    http://x.x.26.4:8087/actuator/info
    http://x.x.26.3:8087/actuator/info
    http://x.x.26.9:8086/actuator/info
    http://x.x.26.8:8086/actuator/info
    
    Process finished with exit code 0
    
    
    
    <!doctype html>
    <!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
    <!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
    <!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
    <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
      <head>
        <base href="/">
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Eureka</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">
    
        <link rel="stylesheet" href="eureka/css/wro.css">
    
      </head>
    
      <body id="one">
    <nav class="navbar navbar-default" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <a class="navbar-brand" href=""><span></span></a>
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav navbar-right">
            <li>
              <a href="">Home</a>
            </li>
            <li>
              <a href="/lastn">Last 1000 since startup</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>
    
    
        <div class="container-fluid xd-container">
    <h1>System Status</h1>
    <div class="row">
      <div class="col-md-6">
        <table id='instances' class="table table-condensed table-striped table-hover">
                <tr>
            <td>Environment</td>
            <td>test</td>
          </tr>
          <tr>
            <td>Data center</td>
            <td>default</td>
          </tr>
        </table>
      </div>
      <div class="col-md-6">
        <table id='instances' class="table table-condensed table-striped table-hover">
          <tr>
            <td>Current time</td>
            <td>2019-12-30T08:47:14 +0800</td>
          </tr>
          <tr>
            <td>Uptime</td>
            <td>32 days 21:41</td>
          </tr>
          <tr>
            <td>Lease expiration enabled</td>
            <td>true</td>
          </tr>
          <tr>
            <td>Renews threshold</td>
            <td>0</td>
          </tr>
          <tr>
            <td>Renews (last min)</td>
            <td>368</td>
          </tr>
        </table>
      </div>
    </div>
    
        <h4 id="uptime"><font size="+1" color="red"><b>THE SELF PRESERVATION MODE IS TURNED OFF.THIS MAY NOT PROTECT INSTANCE EXPIRY IN CASE OF NETWORK/OTHER PROBLEMS.</b></font></h4>
    
    <h1>DS Replicas</h1>
    <ul class="list-group">
        <li class="list-group-item"><a href="http://x.x.26.8:8761/eureka/">x.x.26.8</a></li>
        <li class="list-group-item"><a href="http://x.x.26.9:8760/eureka/">x.x.26.9</a></li>
    </ul>
    
          <h1>Instances currently registered with Eureka</h1>
          <table id='instances' class="table table-striped table-hover">
            <thead>
              <tr><th>Application</th><th>AMIs</th><th>Availability Zones</th><th>Status</th></tr>
            </thead>
            <tbody>
                  <tr>
                    <td><b>FBSAPIGATEWAY</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.2:7006/actuator/info" target="_blank">ebillsapp2:fbsapigateway:7006</a>
    ,
                            <a href="http://x.x.26.1:7006/actuator/info" target="_blank">ebillsapp1:fbsapigateway:7006</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FBSBOP</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.2:7009/actuator/info" target="_blank">ebillsapp2:fbsbop:7009</a>
    ,
                            <a href="http://x.x.26.1:7009/actuator/info" target="_blank">ebillsapp1:fbsbop:7009</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FBSDISPATCH</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.1:7007/actuator/info" target="_blank">ebillsapp1:fbsdispatch:7007</a>
    ,
                            <a href="http://x.x.26.2:7007/actuator/info" target="_blank">ebillsapp2:fbsdispatch:7007</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FBSINQ</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.2:7008/actuator/info" target="_blank">ebillsapp2:fbsinq:7008</a>
    ,
                            <a href="http://x.x.26.1:7008/actuator/info" target="_blank">ebillsapp1:fbsinq:7008</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FBSJSH</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.1:7002/actuator/info" target="_blank">ebillsapp1:fbsjsh:7002</a>
    ,
                            <a href="http://x.x.26.2:7002/actuator/info" target="_blank">ebillsapp2:fbsjsh:7002</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FBSOTH</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.1:7003/actuator/info" target="_blank">ebillsapp1:fbsoth:7003</a>
    ,
                            <a href="http://x.x.26.2:7003/actuator/info" target="_blank">ebillsapp2:fbsoth:7003</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FBSRCP</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.1:7004/actuator/info" target="_blank">ebillsapp1:fbsrcp:7004</a>
    ,
                            <a href="http://x.x.26.2:7004/actuator/info" target="_blank">ebillsapp2:fbsrcp:7004</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FBSREMIT</b></td>
                    <td>
                        <b>n/a</b> (4)
                    </td>
                    <td>
                        <b></b> (4)
                    </td>
                    <td>
                        <b>UP</b> (4) -
                            <a href="http://x.x.26.1:7005/actuator/info" target="_blank">ebillsapp1:fbsremit:7005</a>
    ,
                            <a href="http://x.x.26.2:7010/actuator/info" target="_blank">ebillsapp2:fbsremit:7010</a>
    ,
                            <a href="http://x.x.26.1:7010/actuator/info" target="_blank">ebillsapp1:fbsremit:7010</a>
    ,
                            <a href="http://x.x.26.2:7005/actuator/info" target="_blank">ebillsapp2:fbsremit:7005</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FBSREPORT</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.2:8020/actuator/info" target="_blank">ebillsapp2:fbsreport:8020</a>
    ,
                            <a href="http://x.x.26.1:8020/actuator/info" target="_blank">ebillsapp1:fbsreport:8020</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FEC</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.4:8082/actuator/info" target="_blank">mcsapp2:fec:8082</a>
    ,
                            <a href="http://x.x.26.3:8082/actuator/info" target="_blank">mcsapp1:fec:8082</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FECAPIGATEWAY</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.4:8085/actuator/info" target="_blank">mcsapp2:fecapigateway:8085</a>
    ,
                            <a href="http://x.x.26.3:8085/actuator/info" target="_blank">mcsapp1:fecapigateway:8085</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FECDISPATCH</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.4:8086/actuator/info" target="_blank">mcsapp2:fecdispatch:8086</a>
    ,
                            <a href="http://x.x.26.3:8086/actuator/info" target="_blank">mcsapp1:fecdispatch:8086</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FECMSGGATEWAY</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.3:8089/actuator/info" target="_blank">mcsapp1:fecmsggateway:8089</a>
    ,
                            <a href="http://x.x.26.4:8089/actuator/info" target="_blank">mcsapp2:fecmsggateway:8089</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>FECREPORT</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.4:8087/actuator/info" target="_blank">mcsapp2:fecreport:8087</a>
    ,
                            <a href="http://x.x.26.3:8087/actuator/info" target="_blank">mcsapp1:fecreport:8087</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>TMS</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://ebillspub2:9999/actuator/info" target="_blank">ebillspub2:tms:9999</a>
    ,
                            <a href="http://ebillspub1:9999/actuator/info" target="_blank">ebillspub1:tms:9999</a>
    
                    </td>
                  </tr>
                  <tr>
                    <td><b>UTAN-GATEWAY-SERVER</b></td>
                    <td>
                        <b>n/a</b> (2)
                    </td>
                    <td>
                        <b></b> (2)
                    </td>
                    <td>
                        <b>UP</b> (2) -
                            <a href="http://x.x.26.9:8086/actuator/info" target="_blank">ebillspub2:utan-gateway-server:8086</a>
    ,
                            <a href="http://x.x.26.8:8086/actuator/info" target="_blank">ebillspub1:utan-gateway-server:8086</a>
    
                    </td>
                  </tr>
    
            </tbody>
          </table>
    
          <h1>General Info</h1>
    
          <table id='generalInfo' class="table table-striped table-hover">
            <thead>
              <tr><th>Name</th><th>Value</th></tr>
            </thead>
            <tbody>
                <tr>
                  <td>total-avail-memory</td><td>971mb</td>
                </tr>
                <tr>
                  <td>environment</td><td>test</td>
                </tr>
                <tr>
                  <td>num-of-cpus</td><td>4</td>
                </tr>
                <tr>
                  <td>current-memory-usage</td><td>358mb (36%)</td>
                </tr>
                <tr>
                  <td>server-uptime</td><td>32 days 21:41</td>
                </tr>
                <tr>
                  <td>registered-replicas</td><td>http://x.x.26.8:8761/eureka/, http://x.x.26.9:8760/eureka/<;/td>
                </tr>
                <tr>
                  <td>unavailable-replicas</td><td>http://x.x.26.8:8761/eureka/,http://x.x.26.9:8760/eureka/,&lt;/td>
                </tr>
                <tr>
                  <td>available-replicas</td><td></td>
                </tr>
            </tbody>
          </table>
    
          <h1>Instance Info</h1>
    
          <table id='instanceInfo' class="table table-striped table-hover">
            <thead>
              <tr><th>Name</th><th>Value</th></tr>
            <thead>
            <tbody>
                <tr>
                  <td>ipAddr</td><td>x.x.26.8</td>
                </tr>
                <tr>
                  <td>status</td><td>UP</td>
                </tr>
            </tbody>
          </table>
        </div>
        <script type="text/javascript" src="eureka/js/wro.js" ></script>
        <script type="text/javascript">
           $(document).ready(function() {
             $('table.stripeable tr:odd').addClass('odd');
             $('table.stripeable tr:even').addClass('even');
           });
        </script>
      </body>
    </html>
    
  • 相关阅读:
    微信推送
    PS学习笔记
    汇编学习笔记
    JAVA学习笔记
    数组作为参数被传递,以及随机数的使用。
    [转]Win7系统中Telnet服务的安装和启动
    电脑高手学习笔记
    Android13.9.15
    C语言9.12
    《将博客搬至CSDN》
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348624.html
Copyright © 2011-2022 走看看