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

2024-06-01 00:08

本文主要是介绍【Python】请求网页数据(urlopen),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

提要:

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

 

贴图: 

代码: 

#encoding: utf-8from urllib import requestres = 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\x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e6\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            </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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xb0\xe6\x8d\xae\xe3\x80\x81\xe8\xae\xbf\xe9\x97\xae\xe6\x95\xb0\xe6\x8d\xae\xe5\xba\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\x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\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\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

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

这篇关于【Python】请求网页数据(urlopen)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1019425

相关文章

Python基础文件操作方法超详细讲解(详解版)

《Python基础文件操作方法超详细讲解(详解版)》文件就是操作系统为用户或应用程序提供的一个读写硬盘的虚拟单位,文件的核心操作就是读和写,:本文主要介绍Python基础文件操作方法超详细讲解的相... 目录一、文件操作1. 文件打开与关闭1.1 打开文件1.2 关闭文件2. 访问模式及说明二、文件读写1.

Python将博客内容html导出为Markdown格式

《Python将博客内容html导出为Markdown格式》Python将博客内容html导出为Markdown格式,通过博客url地址抓取文章,分析并提取出文章标题和内容,将内容构建成html,再转... 目录一、为什么要搞?二、准备如何搞?三、说搞咱就搞!抓取文章提取内容构建html转存markdown

Python获取中国节假日数据记录入JSON文件

《Python获取中国节假日数据记录入JSON文件》项目系统内置的日历应用为了提升用户体验,特别设置了在调休日期显示“休”的UI图标功能,那么问题是这些调休数据从哪里来呢?我尝试一种更为智能的方法:P... 目录节假日数据获取存入jsON文件节假日数据读取封装完整代码项目系统内置的日历应用为了提升用户体验,

Python FastAPI+Celery+RabbitMQ实现分布式图片水印处理系统

《PythonFastAPI+Celery+RabbitMQ实现分布式图片水印处理系统》这篇文章主要为大家详细介绍了PythonFastAPI如何结合Celery以及RabbitMQ实现简单的分布式... 实现思路FastAPI 服务器Celery 任务队列RabbitMQ 作为消息代理定时任务处理完整

Python Websockets库的使用指南

《PythonWebsockets库的使用指南》pythonwebsockets库是一个用于创建WebSocket服务器和客户端的Python库,它提供了一种简单的方式来实现实时通信,支持异步和同步... 目录一、WebSocket 简介二、python 的 websockets 库安装三、完整代码示例1.

揭秘Python Socket网络编程的7种硬核用法

《揭秘PythonSocket网络编程的7种硬核用法》Socket不仅能做聊天室,还能干一大堆硬核操作,这篇文章就带大家看看Python网络编程的7种超实用玩法,感兴趣的小伙伴可以跟随小编一起... 目录1.端口扫描器:探测开放端口2.简易 HTTP 服务器:10 秒搭个网页3.局域网游戏:多人联机对战4.

使用Python实现快速搭建本地HTTP服务器

《使用Python实现快速搭建本地HTTP服务器》:本文主要介绍如何使用Python快速搭建本地HTTP服务器,轻松实现一键HTTP文件共享,同时结合二维码技术,让访问更简单,感兴趣的小伙伴可以了... 目录1. 概述2. 快速搭建 HTTP 文件共享服务2.1 核心思路2.2 代码实现2.3 代码解读3.

Python使用自带的base64库进行base64编码和解码

《Python使用自带的base64库进行base64编码和解码》在Python中,处理数据的编码和解码是数据传输和存储中非常普遍的需求,其中,Base64是一种常用的编码方案,本文我将详细介绍如何使... 目录引言使用python的base64库进行编码和解码编码函数解码函数Base64编码的应用场景注意

Python基于wxPython和FFmpeg开发一个视频标签工具

《Python基于wxPython和FFmpeg开发一个视频标签工具》在当今数字媒体时代,视频内容的管理和标记变得越来越重要,无论是研究人员需要对实验视频进行时间点标记,还是个人用户希望对家庭视频进行... 目录引言1. 应用概述2. 技术栈分析2.1 核心库和模块2.2 wxpython作为GUI选择的优

Java利用JSONPath操作JSON数据的技术指南

《Java利用JSONPath操作JSON数据的技术指南》JSONPath是一种强大的工具,用于查询和操作JSON数据,类似于SQL的语法,它为处理复杂的JSON数据结构提供了简单且高效... 目录1、简述2、什么是 jsONPath?3、Java 示例3.1 基本查询3.2 过滤查询3.3 递归搜索3.4