用户:
cool-creeper查看:4 回复:5 评论:4 创建时间:2020-03-17T12:59:11
【作品展示】

【作品介绍】
用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