【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调用Orator ORM进行数据库操作

《Python调用OratorORM进行数据库操作》OratorORM是一个功能丰富且灵活的PythonORM库,旨在简化数据库操作,它支持多种数据库并提供了简洁且直观的API,下面我们就... 目录Orator ORM 主要特点安装使用示例总结Orator ORM 是一个功能丰富且灵活的 python O

Python使用国内镜像加速pip安装的方法讲解

《Python使用国内镜像加速pip安装的方法讲解》在Python开发中,pip是一个非常重要的工具,用于安装和管理Python的第三方库,然而,在国内使用pip安装依赖时,往往会因为网络问题而导致速... 目录一、pip 工具简介1. 什么是 pip?2. 什么是 -i 参数?二、国内镜像源的选择三、如何

如何使用Java实现请求deepseek

《如何使用Java实现请求deepseek》这篇文章主要为大家详细介绍了如何使用Java实现请求deepseek功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1.deepseek的api创建2.Java实现请求deepseek2.1 pom文件2.2 json转化文件2.2

python使用fastapi实现多语言国际化的操作指南

《python使用fastapi实现多语言国际化的操作指南》本文介绍了使用Python和FastAPI实现多语言国际化的操作指南,包括多语言架构技术栈、翻译管理、前端本地化、语言切换机制以及常见陷阱和... 目录多语言国际化实现指南项目多语言架构技术栈目录结构翻译工作流1. 翻译数据存储2. 翻译生成脚本

Android 悬浮窗开发示例((动态权限请求 | 前台服务和通知 | 悬浮窗创建 )

《Android悬浮窗开发示例((动态权限请求|前台服务和通知|悬浮窗创建)》本文介绍了Android悬浮窗的实现效果,包括动态权限请求、前台服务和通知的使用,悬浮窗权限需要动态申请并引导... 目录一、悬浮窗 动态权限请求1、动态请求权限2、悬浮窗权限说明3、检查动态权限4、申请动态权限5、权限设置完毕后

如何通过Python实现一个消息队列

《如何通过Python实现一个消息队列》这篇文章主要为大家详细介绍了如何通过Python实现一个简单的消息队列,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录如何通过 python 实现消息队列如何把 http 请求放在队列中执行1. 使用 queue.Queue 和 reque

Python如何实现PDF隐私信息检测

《Python如何实现PDF隐私信息检测》随着越来越多的个人信息以电子形式存储和传输,确保这些信息的安全至关重要,本文将介绍如何使用Python检测PDF文件中的隐私信息,需要的可以参考下... 目录项目背景技术栈代码解析功能说明运行结php果在当今,数据隐私保护变得尤为重要。随着越来越多的个人信息以电子形

使用Python快速实现链接转word文档

《使用Python快速实现链接转word文档》这篇文章主要为大家详细介绍了如何使用Python快速实现链接转word文档功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 演示代码展示from newspaper import Articlefrom docx import

Python Jupyter Notebook导包报错问题及解决

《PythonJupyterNotebook导包报错问题及解决》在conda环境中安装包后,JupyterNotebook导入时出现ImportError,可能是由于包版本不对应或版本太高,解决方... 目录问题解决方法重新安装Jupyter NoteBook 更改Kernel总结问题在conda上安装了

Python如何计算两个不同类型列表的相似度

《Python如何计算两个不同类型列表的相似度》在编程中,经常需要比较两个列表的相似度,尤其是当这两个列表包含不同类型的元素时,下面小编就来讲讲如何使用Python计算两个不同类型列表的相似度吧... 目录摘要引言数字类型相似度欧几里得距离曼哈顿距离字符串类型相似度Levenshtein距离Jaccard相