猫史档案馆


【Python作品分享】天气查询器【作品秀】

用户:cool-creepercool-creeper查看:4 回复:5 评论:4 创建时间:2020-03-17T12:59:11


【作品展示】

center_image

 

【作品介绍】

用Python爬虫做的一个天气查询器

 

【作品源代码】

def get_content(url):
    #抓取页面天气数据
    weather_list = []
    html = get_html(url)
    soup = bs4.BeautifulSoup(html,'lxml')
    content_ul = soup.find('div',class_='t').find_all('li')
    forcontentincontent_ul

try:
    weather = {}
    weather['day']= content.find('h1').text
    weather['temperature']= content.find(
    'p',class_='tem').span.text + content.find(
    'p',class_='tem').em.text
    weather_list.append(weather)
except:
    weather_list = []
    print('查询不到')
    print(weather_list)

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
cool-creepercool-creeper

喵是t m

点赞1


评论


SCI氢氧化钡SCI氢氧化钡

赞!

点赞1


评论


星空之忆星空之忆

emmmmm

点赞0


评论


Best超能星Best超能星

连这个都是h    t        m     l变成h喵l。。。。。。。。

点赞0


评论


我叫以赏我叫以赏

我可以打出html(滑稽),教学收费了哈哈哈(doge)

点赞0


评论