|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
大神们好
小弟在尝试爬取墨迹天气
代码如下:
- import requests
- from bs4 import BeautifulSoup
- import sys
- sys.path.append('C:\Python27\Lib\site-packages')
- def open_url():
- url = 'https://tianqi.moji.com/weather/china/guangdong/tianhe-district'
- headers = {
- 'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)',
- 'Host': 'httpbin.org'
- }
- response = requests.get(url, headers = headers)
- print(response.text)
- open_url()
复制代码
运行打印出来的reponse.text的内容只有下面一点点, 原网页的html内容远远不止这些, 请问是我步骤哪里错了吗?
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>服务器ç1å¿™</title>
- <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
- <meta content="yes" name="apple-touch-fullscreen"/>
- <meta name="format-detection" content="telephone=no" />
- <meta name="author" content="mojichina" />
- <style>
- /*css reset*/
- body, firgue { margin:0; }
- body { font:normal normal 1em/1 'Helvetica Neue', Helvetica, Arial, sans-serif; }
- a {outline:none;text-decoration:none; }
- a:hover {outline:none;text-decoration:none; }
- body {
- background:#f4f4f4;
- }
- .queues {
- max-width:640px;
- min-width:320px;
- margin:0 auto;
- text-align:center;
- }
- .queues figure {
- margin:0;
- padding:30px 0 0 0;
- width:100%;
- text-align:center;
- }
- .queues figure img {
- display:inline-block;
- }
- .queues div {
- padding:42px 0 80px 0;
- width:100%;
- text-align:center;
- color:#0097e0;
- font-size:24px;
- line-height:1;
- font-weight:bold;
- }
- .queues a {
- display:inline-block;
- margin:0 auto;
- width:190px;
- height:40px;
- color:#fff;
- font-size:17px;
- line-height:40px;
- text-align:center;
- background:#0097e0;
- border-radius:5px;
- }
- </style>
- </head>
- <body>
- <div class="queues">
- <figure>
- <img src="http://cdn2.moji002.com/webpush/errimg/500.png" width="232" height="166">
- </figure>
- <div>服务器ç1å¿™ èˉ·ç¨åŽå†èˉ•</div>
- <a href="javascript:;" onclick="history.go(-1)" >返回上一é¡μ</a>
- </div>
- </body>
- </html>
复制代码 |
|