请选择 进入手机版 | 继续访问电脑版
设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
查看: 8330|回复: 2

关于查天气(4)的问题

[复制链接]

4

主题

0

好友

44

积分

新手上路

Rank: 1

发表于 2019-4-3 17:02:12 |显示全部楼层
为啥PYTHON 3.7 运行这个链接http://m.weather.com.cn/data3/city%s.xml和教程上的不一样呀,请教大神,出来的是网页代码,而不是城市列表。。。。。难道是借口改了吗?

这是代码:

import urllib.request

url1 = 'http://m.weather.com.cn/data5/city.xml'
content1 = urllib.request.urlopen(url1).read()

content1 = content1.decode('utf8')




print(content1)


这是部分结果:
<html style="font-size: 100px;">

<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport">
    <link rel="apple-touch-icon-precomposed" href="https://i.tq121.com.cn/i/wap/icon.jpg">
    <title>中国天气网-专业天气预报、气象服务门户</title>
    <script type="text/javascript" src="https://i.tq121.com.cn/j/wap2017/base-loading.js?45"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        body {
            background: #ccf2ff;
            font-size: .28rem;
            color: #252525;
            font-family: 'Helvetica';
            -webkit-user-select: none;
            -webkit-text-size-adjust: none;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            max-width: 640px;
            margin: 0 auto;
        }

        .head {
            width: 100%;
            background: #f1f1f1;
            height: .9rem;
            overflow: hidden;

回复

使用道具 举报

174

主题

45

好友

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

发表于 2019-4-4 14:16:56 |显示全部楼层
http://m.weather.com.cn/data3/city.xml 这个接口间歇性可用,最近看来是又不行了
如果要获取 city 信息有其他的方式,参考 查天气 的帖子

https://bbs.crossincode.com/forum.php?mod=viewthread&tid=8
#==== Crossin的编程教室 ====#
微信ID:crossincode
网站:http://crossincode.com
回复

使用道具 举报

4

主题

0

好友

44

积分

新手上路

Rank: 1

发表于 2019-4-7 14:58:08 |显示全部楼层
哟西
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-3-29 17:12 , Processed in 0.014957 second(s), 22 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部