#プログラミング #python #副業
import requests
import pandas as pd
from bs4 import BeautifulSoup
yeaar = [2019,2020,2021,2022]
for nen in yeaar:
url = "www.data.jma.g..."+str(nen)+"&month=1&day=1&view="
response=requests.get(url)
soup = BeautifulSoup(response.content,"html.parser") #バイナリーデータ PCが読めるすべてのデータ
all_data=soup.find_all(class_="data_0_0")
zz=int(zi_list[-1])
df=pd.DataFrame(columns = ['現地' , '海面', '降水量', '気温', '露点', '蒸気圧', '湿度', '風速', '風向', '日照', '全天', '降雪', '積雪',"天気","雲量","視程"])
list_data = []
count = 0
for kk in range(zz):
for t in range(16):
list_data.append(all_data[count].text)
count = count +1
df.loc[kk]=list_data
list_data = []
df.to_excel("D:\\youtube\\気象庁ウェブスクレイピング\\"+str(nen)+".xlsx")
29 авг 2024