python爬虫包含gui界面的完整版_爬虫-天气查询程序【GUI界面版】,Python交流,技术交流区,鱼C论坛 - Powered by Discuz!...

import urllib.request

import gzip

import json

import easygui as g

g.msgbox("------天气查询------")

def get_weather_data() :

msg = "请输入要查询的城市名称:"

title = "天气查询器"

city_name = g.enterbox(msg, title)

#city_name = input('请输入要查询的城市名称:')

url1 = 'http://wthrcdn.etouch.cn/weather_mini?city='+urllib.parse.quote(city_name)

url2 = 'http://wthrcdn.etouch.cn/weather_mini?citykey=101010100'

#网址1只需要输入城市名,网址2需要输入城市代码

#print(url1)

weather_data = urllib.request.urlopen(url1).read()

#读取网页数据

weather_data = gzip.decompress(weather_data).decode('utf-8')

#解压网页数据

weather_dict = json.loads(weather_data)

#将json数据转换为dict数据

return weather_dict

def query_weather(weather_dict):

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值