资源简介
python爬取网络历史天气数据
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Fri May 19 17:10:31 2017
@author: Starry_JM
“““
from bs4 import BeautifulSoup
import requests
import xlwt
import os
#获得某一个月的天气数据
def getListByUrl(url):
res = requests.get(url)
soup = BeautifulSoup(res.text“html.parser“)
weathers = soup.select(“#tool_site“)
title = weathers[1].select(“h3“)[0].text
weatherInfors = weathers[1].select(“ul“)
weatherList = list()
for weatherInfor in weatherInfors:
singleWeather = list()
for li in weatherInfor.select(‘li‘):
singleWeather.append(li.text)
weatherList.append(singleWeather)
print(title)
return weatherListtitle
#@par:addressUrl 获得某地区的数据
#@par:excelSavePath 数据的保存地址
def getListByAddress(addressUrlexcelSaveP
- 上一篇:crc32碰撞python
- 下一篇:Python采集百度地图数据.zip
评论
共有 条评论