날씨, 미세먼지 농도
날씨와 미세먼지 농도를 가져옵시다.
Last updated
날씨와 미세먼지 농도를 가져옵시다.
Last updated
<li class="nm">흐리고 비</li>
<span class="temp"><strong>11</strong>℃"</span>
<span class="rain"><strong>80</strong>%</span># -*- coding: UTF-8 -*-
from bs4 import BeautifulSoup
import requests
URL = "https://weather.naver.com/rgn/cityWetrMain.nhn" #지역별 날씨
html = requests.get(URL).text
soup = BeautifulSoup(html, 'html.parser')
print(soup)from bs4 import BeautifulSoup
import requests
URL = "https://weather.naver.com/rgn/cityWetrMain.nhn" #지역별 날씨
html = requests.get(URL).text
soup = BeautifulSoup(html, 'html.parser')
watherTable = soup.find_all("li", class_="nm")
print(watherTable)# -*- coding: UTF-8 -*-
from bs4 import BeautifulSoup
import requests
URL = "https://weather.naver.com/rgn/cityWetrMain.nhn" #지역별 날씨
html = requests.get(URL).text
soup = BeautifulSoup(html, 'html.parser')
watherTable = soup.find_all("li", class_="nm")
print(watherTable)
tempTable = soup.find_all("span", class_="temp")
print(tempTable)
rainTable = soup.find_all("span", class_="rain")
print(rainTable)# -*- coding: UTF-8 -*-
from bs4 import BeautifulSoup
import requests
URL = "https://weather.naver.com/rgn/cityWetrMain.nhn" #지역별 날씨
html = requests.get(URL).text
soup = BeautifulSoup(html, 'html.parser')
watherTable = soup.find_all("li", class_="nm")
tempTable = soup.find_all("span", class_="temp")
rainTable = soup.find_all("span", class_="rain")
print(watherTable[0].text)
print(tempTable[0].text)
print(rainTable[0].text)# -*- coding: UTF-8 -*-
from bs4 import BeautifulSoup
import requests
URL = "https://weather.naver.com/air/airFcast.nhn" #미세먼지
html = requests.get(URL).text
soup = BeautifulSoup(html, 'html.parser')
airTable = soup.find_all("div", class_="list_air_inn")
for air in airTable:
today = air.find_all("li")
for data in today:
print(data.text)