91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .py
    金幣: 1
    下載: 0 次
    發布日期: 2021-01-07
  • 語言: Python
  • 標簽: python天氣??

資源簡介

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

評論

共有 條評論

相關資源