【Python】请求网页数据(urlopen)

提要:

1.urlopen(URL) 可以返回URL对应网页的数据

 

贴图: 

代码: 

#encoding: utf-8

from urllib import request

res = request.urlopen("http://47.94.171.17:8080")
print(res.read())

返回结果: 

G:\PythonProject\Demo1\venv\Scripts\python.exe G:/PythonProject/Demo1/demo.py
b'<!---\xe5\xb1\x95\xe7\xa4\xba\xe6\x89\x80\xe6\x9c\x89\xe7\x9a\x84\xe5\x8d\x9a\xe5\xae\xa2-->\r\n<!DOCTYPE html>\r\n<html lang="en">\r\n<head>\r\n    <meta charset="UTF-8">\r\n    <meta name="viewport" content="width=device-width, initial-scale=1.0">\r\n    <meta http-equiv="X-UA-Compatible" content="ie=edge">\r\n    <meta name="viewport" content="width=device-width, initial-scale=1.0">\r\n    <link rel="stylesheet" href="/static/bt/css/bootstrap.min.css">\r\n    <link rel="stylesheet" href="/static/bt/css/bootstrap-theme.min.css">\r\n    <script src="/static/bt/js/jquery.js"></script>\r\n    <script src="/static/bt/js/bootstrap.js"></script>\r\n    <script src="/static/bt/js/cookie.js"></script>\r\n    <script src="/static/bt/js/jquery_md5.js"></script>\r\n    <script src="/static/bt/js/holder.js"></script>    \r\n    <title>Yy\xe7\xa7\x91\xe6\x8a\x80\xe5\x9f\x8e-\xe4\xb8\xaa\xe4\xba\xba\xe5\x8d\x9a\xe5\xae\xa2\xe7\xb3\xbb\xe7\xbb\x9f</title>\r\n</head>\r\n<body>\r\n    <div class="container-fluid">\r\n\r\n        <!---\xe5\xaf\xbc\xe8\x88\xaa\xe5\xbc\x80\xe5\xa7\x8b-->\r\n\r\n        <nav class="navbar navbar-default" role="navigation">\r\n            <div class="container-fluid">\r\n              <!-- Brand and toggle get grouped for better mobile display -->\r\n              <div class="navbar-header">\r\n                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">\r\n                  <span class="sr-only">Toggle navigation</span>\r\n                  <span class="icon-bar"></span>\r\n                  <span class="icon-bar"></span>\r\n                  <span class="icon-bar"></span>\r\n                </button>\r\n                <a class="navbar-brand" href="/index/index/index.html">Yy-BLog</a>\r\n              </div>\r\n          \r\n              <!-- Collect the nav links, forms, and other content for toggling -->\r\n              <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">\r\n                <ul class="nav navbar-nav">\r\n                  <li class="active"><a href="/index/index/index.html">\xe9\xa6\x96\xe9\xa1\xb5 <span class="sr-only">(current)</span></a></li>\r\n                  <li><a href="#">\xe8\xb5\x84\xe6\xba\x90\xe4\xb8\x8b\xe8\xbd\xbd</a></li>\r\n                  <li class="dropdown">\r\n                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Blog\xe5\x88\x86\xe7\xb1\xbb <span class="caret"></span></a>\r\n                    <ul class="dropdown-menu">\r\n                        <!----\xe5\x88\x86\xe7\xb1\xbb\xe5\xbc\x80\xe5\xa7\x8b-->\r\n                      <li><a href="#">Action</a></li>\r\n                      <li role="separator" class="divider"></li>\r\n                      <li><a href="#">Separated link</a></li>\r\n                      <li role="separator" class="divider"></li>\r\n                      <li><a href="#">One more separated link</a></li>\r\n                      <!----\xe5\x88\x86\xe7\xb1\xbb\xe7\xbb\x93\xe6\x9d\x9f-->\r\n                    </ul>\r\n                  </li>\r\n                </ul>\r\n                <form class="navbar-form navbar-left">\r\n                  <div class="form-group">\r\n                    <input type="text" class="form-control" placeholder="\xe8\xbe\x93\xe5\x85\xa5\xe6\x82\xa8\xe8\xa6\x81\xe6\x90\x9c\xe7\xb4\xa2\xe7\x9a\x84\xe5\x86\x85\xe5\xae\xb9">\r\n                  </div>\r\n                  <button type="submit" class="btn btn-default">\xe6\x90\x9c\xe7\xb4\xa2</button>\r\n                </form>\r\n                <ul class="nav navbar-nav navbar-right">\r\n                    <li class="dropdown">                                             <!--\xe5\x8f\xaa\xe8\xa6\x81\xe4\xb8\x8d\xe6\x98\xafdropdown \xe5\xb0\xb1\xe4\xb8\x8d\xe4\xbc\x9a\xe5\xbc\xb9\xe5\x87\xba\xe4\xb8\x8b\xe6\x8b\x89\xe8\x8f\x9c\xe5\x8d\x95-->\r\n                    <a href="/index/user/login.html" class="dropdown-toggle UserLogin" data-toggle="" role="button" aria-haspopup="true" aria-expanded="false">\xe7\x94\xa8\xe6\x88\xb7\xe7\x99\xbb\xe5\xbd\x95 <span class="caret"></span></a>\r\n                    <ul class="dropdown-menu">\r\n                      <li><a href="/index/index/writecomments.html" class="glyphicon glyphicon-pencil">\xe5\x86\x99\xe5\x8d\x9a\xe5\xae\xa2</a></li>\r\n                      <li><a href="#" class="glyphicon glyphicon-th-list">\xe7\xae\xa1\xe7\x90\x86\xe5\x8d\x9a\xe5\xae\xa2</a></li>\r\n                      <li role="separator" class="divider"></li>\r\n                      <li><a href="#" class="glyphicon glyphicon-user">\xe4\xb8\xaa\xe4\xba\xba\xe4\xb8\xad\xe5\xbf\x83</a></li>\r\n                      <li><a href="#" class="glyphicon glyphicon-off">\xe9\x80\x80\xe5\x87\xba\xe7\x99\xbb\xe5\xbd\x95</a></li>\r\n                    </ul>\r\n                  </li>\r\n                  <li><a href="#">\xe5\x90\x8e\xe5\x8f\xb0\xe7\xae\xa1\xe7\x90\x86</a></li>\r\n                  <li class="dropdown">\r\n                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">\xe5\x95\x86\xe4\xb8\x9a\xe5\x90\x88\xe4\xbd\x9c <span class="caret"></span></a>\r\n                    <ul class="dropdown-menu">\r\n                      <li><a href="#">Action</a></li>\r\n                      <li><a href="#">Another action</a></li>\r\n                      <li><a href="#">Something else here</a></li>\r\n                      <li role="separator" class="divider"></li>\r\n                      <li><a href="#">Separated link</a></li>\r\n                    </ul>\r\n                  </li>\r\n                </ul>\r\n              </div><!-- /.navbar-collapse -->\r\n            </div><!-- /.container-fluid -->\r\n          </nav>\r\n          \r\n\r\n        <!---\xe5\xaf\xbc\xe8\x88\xaa\xe7\xbb\x93\xe6\x9d\x9f-->\r\n\r\n        <!---\xe5\xb7\xa6\xe4\xbe\xa7\xe8\xbe\xb9\xe6\xa0\x8f\xe5\xbc\x80\xe5\xa7\x8b-->\r\n        <div class="col-xs-0 col-sm-0 col-md-3 hidden-xs hidden-sm" style="height: 100%">\r\n\r\n\r\n            <div class="list-group">\r\n                <a href="/index/index/index.html" class="list-group-item panel panel-info">\xe5\x85\xa8\xe9\x83\xa8\xe5\x88\x86\xe7\xb1\xbb</a>\r\n                <a class="list-group-item active">\r\n                    \xe5\x89\x8d\xe7\xab\xaf\xe5\x88\x86\xe7\xb1\xbb\r\n                </a>\r\n                <a href="/index/index/showtype/Type/HTML.html" class="list-group-item">HTML</a>\r\n                <a href="/index/index/showtype/Type/JavaScript.html" class="list-group-item">JavaScript</a>\r\n                <a href="/index/index/showtype/Type/JQuery.html" class="list-group-item">JQuery</a>\r\n                <a href="/index/index/showtype/Type/Bootstrap.html" class="list-group-item">Bootstrap</a>\r\n            </div>\r\n\r\n\r\n            <div class="list-group">\r\n                <a class="list-group-item active">\r\n                    \xe5\x90\x8e\xe7\xab\xaf\xe5\x88\x86\xe7\xb1\xbb\r\n                </a>\r\n                <a href="/index/index/showtype/Type/JSP.html" class="list-group-item">JSP</a>\r\n                <a href="/index/index/showtype/Type/PHP.html" class="list-group-item">PHP</a>\r\n                <a href="/index/index/showtype/Type/ThinkPHP.html" class="list-group-item">ThinkPHP</a>\r\n                <a href="/index/index/showtype/Type/node.js.html" class="list-group-item">node.js</a>\r\n            </div>\r\n\r\n            <div class="list-group">\r\n                <a class="list-group-item active">\r\n                    \xe8\xbd\xaf\xe4\xbb\xb6\xe5\xbc\x80\xe5\x8f\x91\r\n                </a>\r\n                <a href="/index/index/showtype/Type/%E6%98%93%E8%AF%AD%E8%A8%80.html" class="list-group-item">\xe6\x98\x93\xe8\xaf\xad\xe8\xa8\x80</a>\r\n                <a href="/index/index/showtype/Type/C%2B%2B.html" class="list-group-item">C++</a>\r\n                <a href="/index/index/showtype/Type/C%E8%AF%AD%E8%A8%80.html" class="list-group-item">C\xe8\xaf\xad\xe8\xa8\x80</a>\r\n                <a href="/index/index/showtype/Type/Python.html" class="list-group-item">Python</a>\r\n            </div>\r\n\r\n\r\n        </div>\r\n        <!---\xe5\xb7\xa6\xe4\xbe\xa7\xe8\xbe\xb9\xe6\xa0\x8f\xe7\xbb\x93\xe6\x9d\x9f-->\r\n\r\n        <!---\xe5\x8f\xb3\xe4\xbe\xa7\xe8\xbe\xb9\xe6\xa0\x8f\xe5\xbc\x80\xe5\xa7\x8b-->\r\n        <div class="col-xs-12 col-sm-12 col-md-9" style="height: 100%">\r\n        \r\n            <div class="panel panel-info">\r\n            <div class="panel-heading">Welcome</div>\r\n            <div class="panel-body">\r\n                <p>\xe8\xbf\x99\xe9\x87\x8c\xe6\x98\xbe\xe7\xa4\xba\xe6\x89\x80\xe6\x9c\x89\xe7\x9a\x84\xe6\x8a\x80\xe6\x9c\xaf\xe5\x88\x86\xe7\xb1\xbb,\xe5\x9c\xa8\xe8\xbf\x99\xe9\x87\x8c\xe6\x82\xa8\xe5\x8f\xaf\xe4\xbb\xa5\xe6\x9f\xa5\xe7\x9c\x8b\xe6\x89\x80\xe6\x9c\x89\xe4\xba\xba\xe5\x86\x99\xe7\x9a\x84\xe6\x89\x80\xe6\x9c\x89\xe5\x88\x86\xe7\xb1\xbb\xe7\x9a\x84\xe5\x8d\x9a\xe5\xae\xa2\xe3\x80\x82\xe5\x8d\xb3\xe4\xbd\xbf\xe6\x82\xa8\xe6\x98\xaf\xe6\xb8\xb8\xe5\xae\xa2\xe6\x82\xa8\xe4\xb9\x9f\xe5\x8f\xaf\xe4\xbb\xa5\xe6\x9f\xa5\xe7\x9c\x8b\xe3\x80\x81\xe5\xa4\x8d\xe5\x88\xb6 </p>\r\n                <p>\xe5\xa6\x82\xe6\x9e\x9c\xe6\x82\xa8\xe4\xb9\x9f\xe6\x83\xb3\xe5\x8a\xa0\xe5\x85\xa5\xe6\x88\x91\xe4\xbb\xac,\xe9\x82\xa3\xe4\xb9\x88\xe5\xb0\xb1\xe7\x94\xb3\xe8\xaf\xb7\xe4\xb8\x80\xe4\xb8\xaa\xe8\xb4\xa6\xe5\x8f\xb7 \xe6\x97\xa0\xe9\x9c\x80\xe7\xbc\xb4\xe8\xb4\xb9,\xe9\x9b\xb6\xe9\x97\xa8\xe6\xa7\x9b</p>\r\n            </div>\r\n            </div>\r\n            <!--\xe5\xbc\x80\xe5\xa7\x8b\xe5\xbe\xaa\xe7\x8e\xaf-->\r\n                        <div class="panel panel-success">\r\n            <div class="panel-heading">\r\n                <h3 class="panel-title" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">\r\n                  \r\n                  <a href="/index/index/showinfo/id/1.html" target="_blank" class="glyphicon glyphicon-envelope">\xe6\xb7\xbb\xe5\x8a\xa0\xe4\xba\x86\xe6\x98\xbe\xe7\xa4\xba\xe6\x96\x87\xe6\x9c\xac \xe6\xb5\x8b\xe8\xaf\x95\xe5\x85\xb6\xe5\x8a\x9f\xe8\x83\xbd </a>\r\n                  \r\n                  <span class="label label-danger">Type:HTML</span>\r\n                  <span class="label label-warning">Views:11</span>  \r\n                </h3>\r\n            </div>\r\n            <div class="panel-body"  style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">\r\n                \xe6\xb7\xbb\xe5\x8a\xa0\xe4\xba\x86\xe6\x98\xbe\xe7\xa4\xba\xe6\x96\x87\xe6\x9c\xac \xe6\xb5\x8b\xe8\xaf\x95\xe5\x85\xb6\xe5\x8a\x9f\xe8\x83\xbd\xe6\xb7\xbb\xe5\x8a\xa0\xe4\xba\x86\xe6\x98\xbe\xe7\xa4\xba\xe6\x96\x87\xe6\x9c\xac \xe6\xb5\x8b\xe8\xaf\x95\xe5\x85\xb6\xe5\x8a\x9f\xe8\x83\xbd\xe6\xb7\xbb\xe5\x8a\xa0\xe4\xba\x86\xe6\x98\xbe\xe7\xa4\xba\xe6\x96\x87\xe6\x9c\xac \xe6\xb5\x8b\xe8\xaf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\xe5\x8a\x9f\xe8\x83\xbd\xe6\xb7\xbb\xe5\x8a\xa0\xe4\xba\x86\xe6\x98\xbe\xe7\xa4\xba\xe6\x96\x87\xe6\x9c\xac \xe6\xb5\x8b\xe8\xaf\x95\xe5\x85\xb6\xe5\x8a\x9f\xe8\x83\xbd\xe6\xb7\xbb\xe5\x8a\xa0\xe4\xba\x86\xe6\x98\xbe\xe7\xa4\xba\xe6\x96\x87            </div>\r\n              <span class="label label-define"  style="float:right; color:red">2019-04-07</span>\r\n                <span class="label label-info" style="float:right;">\r\n                    <a href="/index/index/showinfo/id/1.html" target="_blank">\xe6\x9f\xa5\xe7\x9c\x8b\xe5\x85\xa8\xe6\x96\x87</a>\r\n                    \r\n                </span>\r\n            </div>            \r\n                        <div class="panel panel-success">\r\n            <div class="panel-heading">\r\n                <h3 class="panel-title" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">\r\n                  \r\n                  <a href="/index/index/showinfo/id/2.html" target="_blank" class="glyphicon glyphicon-envelope">JSP \xe7\xae\x80\xe4\xbb\x8b </a>\r\n                  \r\n                  <span class="label label-danger">Type:JSP</span>\r\n                  <span class="label label-warning">Views:7</span>  \r\n                </h3>\r\n            </div>\r\n            <div class="panel-body"  style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">\r\n                JSP \xe7\xae\x80\xe4\xbb\x8b\xe4\xbb\x80\xe4\xb9\x88\xe6\x98\xafJava Server Pages?JSP\xe5\x85\xa8\xe7\xa7\xb0Java Server Pages\xef\xbc\x8c\xe6\x98\xaf\xe4\xb8\x80\xe7\xa7\x8d\xe5\x8a\xa8\xe6\x80\x81\xe7\xbd\x91\xe9\xa1\xb5\xe5\xbc\x80\xe5\x8f\x91\xe6\x8a\x80\xe6\x9c\xaf\xe3\x80\x82\xe5\xae\x83\xe4\xbd\xbf\xe7\x94\xa8JSP\xe6\xa0\x87\xe7\xad\xbe\xe5\x9c\xa8HTML\xe7\xbd\x91\xe9\xa1\xb5\xe4\xb8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x93\xe5\x8f\x8a\xe5\x85\xb6\xe4\xbb\x96\xe6\x95\xb0\xe6\x8d\xae\xe6\xba\x90\xef\xbc\x8c\xe7\x84\xb6\xe5\x90\x8e\xe5\x8a\xa8\xe6\x80\x81\xe5\x9c\xb0\xe5\x88\x9b\xe5\xbb\xba\xe7\xbd\x91\xe9\xa1\xb5\xe3\x80\x82JSP\xe6\xa0\x87\xe7\xad\xbe\xe6\x9c\x89\xe5\xa4\x9a\xe7\xa7\x8d\xe5\x8a\x9f\xe8\x83\xbd\xef\xbc\x8c\xe6\xaf\x94\xe5\xa6\x82\xe8\xae\xbf\xe9\x97\xae\xe6\x95\xb0\xe6\x8d\xae\xe5\xba\x93\xe3\x80\x81            </div>\r\n              <span class="label label-define"  style="float:right; color:red">2019-04-09</span>\r\n                <span class="label label-info" style="float:right;">\r\n                    <a href="/index/index/showinfo/id/2.html" target="_blank">\xe6\x9f\xa5\xe7\x9c\x8b\xe5\x85\xa8\xe6\x96\x87</a>\r\n                    \r\n                </span>\r\n            </div>            \r\n                        <div class="panel panel-success">\r\n            <div class="panel-heading">\r\n                <h3 class="panel-title" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">\r\n                  \r\n                  <a href="/index/index/showinfo/id/3.html" target="_blank" class="glyphicon glyphicon-envelope">JSP \xe9\xa1\xb5\xe9\x9d\xa2\xe9\x87\x8d\xe5\xae\x9a\xe5\x90\x91 </a>\r\n                  \r\n                  <span class="label label-danger">Type:JSP</span>\r\n                  <span class="label label-warning">Views:1</span>  \r\n                </h3>\r\n            </div>\r\n            <div class="panel-body"  style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">\r\n                JSP \xe9\xa1\xb5\xe9\x9d\xa2\xe9\x87\x8d\xe5\xae\x9a\xe5\x90\x91\xe5\xbd\x93\xe9\x9c\x80\xe8\xa6\x81\xe5\xb0\x86\xe6\x96\x87\xe6\xa1\xa3\xe7\xa7\xbb\xe5\x8a\xa8\xe5\x88\xb0\xe4\xb8\x80\xe4\xb8\xaa\xe6\x96\xb0\xe7\x9a\x84\xe4\xbd\x8d\xe7\xbd\xae\xe6\x97\xb6\xef\xbc\x8c\xe5\xb0\xb1\xe9\x9c\x80\xe8\xa6\x81\xe4\xbd\xbf\xe7\x94\xa8JSP\xe9\x87\x8d\xe5\xae\x9a\xe5\x90\x91\xe4\xba\x86\xe3\x80\x82\xe6\x9c\x80\xe7\xae\x80\xe5\x8d\x95\xe7\x9a\x84\xe9\x87\x8d\xe5\xae\x9a\xe5\x90\x91\xe6\x96\xb9\xe5\xbc\x8f\xe5\xb0\xb1\xe6\x98\xaf\xe4\xbd\xbf\xe7\x94\xa8response\xe5\xaf\xb9\xe8\xb1\xa1\xe7\x9a\x84sendRedirect()\xe6\x96\xb9\xe6\xb3\x95\xe3\x80\x82\xe8\xbf\x99\xe4\xb8\xaa\xe6\x96\xb9\xe6\xb3\x95\xe7\x9a\x84\xe7\xad\xbe\xe5\x90\x8d\xe5\xa6\x82\xe4\xb8\x8b\xef\xbc\x9apublic void response.sendRedirect(String location)throws IOException \xe8\xbf\x99\xe4\xb8\xaa\xe6\x96\xb9\xe6\xb3\x95\xe5\xb0\x86\xe7\x8a\xb6\xe6\x80\x81\xe7\xa0\x81\xe5\x92\x8c\xe6\x96\xb0\xe7\x9a\x84\xe9\xa1\xb5\xe9\x9d\xa2\xe4\xbd\x8d\xe7\xbd\xae\xe4\xbd\x9c\xe4\xb8\xba\xe5\x93\x8d\xe5\xba\x94\xe5\x8f\x91\xe5\x9b\x9e\xe7\xbb\x99\xe6\xb5\x8f\xe8\xa7\x88\xe5\x99\xa8\xe3\x80\x82\xe6\x82\xa8\xe4\xb9\x9f\xe5\x8f\xaf\xe4\xbb\xa5\xe4\xbd\xbf\xe7\x94\xa8setStatus()\xe5\x92\x8csetHeader()\xe6\x96\xb9\xe6\xb3\x95\xe6\x9d\xa5\xe5\xbe\x97\xe5\x88\xb0\xe5\x90\x8c\xe6\xa0\xb7\xe7\x9a\x84\xe6\x95\x88\xe6\x9e\x9c\xef\xbc\x9a....String site = "http://www.            </div>\r\n              <span class="label label-define"  style="float:right; color:red">2019-04-09</span>\r\n                <span class="label label-info" style="float:right;">\r\n                    <a href="/index/index/showinfo/id/3.html" target="_blank">\xe6\x9f\xa5\xe7\x9c\x8b\xe5\x85\xa8\xe6\x96\x87</a>\r\n                    \r\n                </span>\r\n            </div>            \r\n                        <div class="panel panel-success">\r\n            <div class="panel-heading">\r\n                <h3 class="panel-title" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">\r\n                  \r\n                  <a href="/index/index/showinfo/id/4.html" target="_blank" class="glyphicon glyphicon-envelope">\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84 </a>\r\n                  \r\n                  <span class="label label-danger">Type:HTML</span>\r\n                  <span class="label label-warning">Views:1</span>  \r\n                </h3>\r\n            </div>\r\n            <div class="panel-body"  style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">\r\n                \xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\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af\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88\xe5\xa5\xbd\xe8\xaf\xb4\xe7\x9a\x84\xe6\xb2\xa1\xe4\xbb\x80\xe4\xb9\x88            </div>\r\n              <span class="label label-define"  style="float:right; color:red">2019-04-09</span>\r\n                <span class="label label-info" style="float:right;">\r\n                    <a href="/index/index/showinfo/id/4.html" target="_blank">\xe6\x9f\xa5\xe7\x9c\x8b\xe5\x85\xa8\xe6\x96\x87</a>\r\n                    \r\n                </span>\r\n            </div>            \r\n                        <!--\xe7\xbb\x93\xe6\x9d\x9f\xe5\xbe\xaa\xe7\x8e\xaf-->\r\n            <center><ul class="pagination"><li class="disabled"><span>&laquo;</span></li> <li class="active"><span>1</span></li><li><a href="/?page=2">2</a></li> <li><a href="/?page=2">&raquo;</a></li></ul></center>\r\n            \r\n        </div>\r\n\r\n        <!---\xe5\x8f\xb3\xe4\xbe\xa7\xe8\xbe\xb9\xe6\xa0\x8f\xe7\xbb\x93\xe6\x9d\x9f-->\r\n\r\n\r\n\r\n    </div>\r\n    <!--\xe9\xa1\xb5\xe8\x84\x9a\xe5\xbc\x80\xe5\xa7\x8b-->\r\n    <div class="container">\r\n        <div class="panel-footer">\r\n            <center>\xe6\x9c\x80\xe7\xbb\x88\xe7\x89\x88\xe6\x9d\x83\xe5\xbd\x92Yy\xe7\xa7\x91\xe6\x8a\x80\xe5\x9f\x8e\xe6\x89\x80\xe6\x9c\x89</center>\r\n        </div>\r\n    </div>\r\n    <!--\xe9\xa1\xb5\xe8\x84\x9a\xe7\xbb\x93\xe6\x9d\x9f-->\r\n</body>\r\n\r\n<script>\r\n$(function(){\r\n\r\n    \r\n$(\'body\').hide(500);\r\n$(\'body\').show(1000);\r\n//\xe5\x88\xa4\xe6\x96\xad\xe7\x94\xa8\xe6\x88\xb7Cookie\xe6\x98\xaf\xe5\x90\xa6\xe5\xad\x98\xe5\x9c\xa8\r\nvar Token = $.cookie("UserToken");\r\n$.ajax({\r\n    url:"/index/user/checktoken.html",\r\n    type:\'POST\',\r\n    data:{Token:Token},\r\n    success:function(data){\r\n        if(data.mag == \'1\'){\r\n          //\xe7\x99\xbb\xe5\xbd\x95\xe6\x88\x90\xe5\x8a\x9f\r\n          $(\'.UserLogin\').html(data.UserName + "  <span class=\'caret\'></span>");\r\n          $(\'.UserLogin\').attr(\'data-toggle\',\'dropdown\');\r\n        }\r\n\r\n        if(data.mag == \'0\'){\r\n          $(\'.UserLogin\').html("\xe7\x94\xa8\xe6\x88\xb7\xe7\x99\xbb\xe5\xbd\x95");\r\n        }\r\n\r\n        if(data.mag == \'-1\'){\r\n          $.cookie(\'Token\', null,{ expires: 7, path: \'/\' });\r\n          alert(data.other);\r\n        }\r\n    }\r\n});\r\n\r\n\r\n//\xe7\x99\xbb\xe5\xbd\x95\xe6\x88\x90\xe5\x8a\x9f\r\n//$(\'.UserLogin\').attr(\'data-toggle\',\'dropdown\');\r\n//UserLogin\r\n});\r\n</script>\r\n</html>'

Process finished with exit code 0

当然未经过解码后的数据中文是不显示的,具体编码我们后面再说

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#coding:utf-8 import time import webbrowser as web import os import random #随机选择一个浏览器打开网页 def open_url_use_random_browser(): #定义要访问的地址 url='http://www.baidu.com' #定义浏览器路径 browser_paths=[r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe', #r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe', #r'C:\Program Files (x86)\Opera\launcher.exe', #r'C:\Users\Administrator\AppData\Roaming\qianying\qianying.exe', #r'C:\Users\Administrator\AppData\Local\115Chrome\Application\115chrome.exe', #r'C:\Program Files (x86)\Internet Explorer\iexplore.exe', #r'D:\Program Files(x86)\SouExplorer\SogouExplorer\SogouExplorer.exe' ] #选择一个浏览器 def chose_a_browser_open_url(browser_path,url): #如果传入的浏览器位置不存在,使用默认的浏览器打开 if not browser_path: print ('using default browser to open') web.open_new_tab(url)#使用默认浏览器,就不再结束进程 else: #判断浏览器路径是否存在 if not os.path.exists(browser_path): print ('current browser path not exists,using default browser') #浏览器位置不存在就使用默认的浏览器打开 browser_path='' chose_a_browser_open_url(chose_a_browser_open_url,url) else: browser_task_name=browser_path.split('\\')[-1]#结束任务的名字 browser_name=browser_task_name.split('.')[0]#自定义的浏览器代号 print (browser_name) web.register(browser_name, None,web.BackgroundBrowser(browser_path)) web.get(browser_name).open_new_tab(url)#使用新注册的浏览器打开网页 print ('using %s browser open url successful' % browser_name) time.sleep(5)#等待打开浏览器 # kill_cmd='taskkill /f /IM '+browser_task_name#拼接结束浏览器进程的命令 # os.system(kill_cmd) #终结浏览器 browser_path=random.choice(browser_paths)#随机从浏览器中选择一个路径 chose_a_browser_open_url(browser_path,url) if __name__ == '__main__': print (''''' ***************************************** ** Welcome to python of browser ** ** Created on 2019-04-28 ** ** @author: Louise_ZOU ** ***************************************** ''') open_url_use_random_browser()

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值