from bs4 import BeautifulSoup
import urllib.request as req
url = "<https://finance.naver.com/marketindex/>" # 시장지표
res = req.urlopen(url) # html 객체
soup = BeautifulSoup(res, "html.parser")
soup

from bs4 import BeautifulSoup
import urllib.request as req
url = "<https://finance.naver.com/marketindex/>" # 시장지표
res = req.urlopen(url) # html 객체
soup = BeautifulSoup(res, "html.parser")
# 미국 달러 환율
usd = soup.select_one("a.head.usd > div.head_info > span.value").string
usd

from bs4 import BeautifulSoup
import urllib.request as req
url = "<https://finance.naver.com/marketindex/>" # 시장지표
res = req.urlopen(url) # html 객체
soup = BeautifulSoup(res, "html.parser")
# 미국 달러 환율
usd = soup.select_one("a.head.usd > div.head_info > span.value").string
# 휘발유
gasoline = soup.select_one("a.head.gasoline > div.head_info > span.value").string
gasoline

from bs4 import BeautifulSoup
import urllib.request as req
url = "<https://finance.naver.com/marketindex/>" # 시장지표
res = req.urlopen(url) # html 객체
soup = BeautifulSoup(res, "html.parser")
# 미국 달러 환율
usd = soup.select_one("a.head.usd > div.head_info > span.value").string
# 휘발유
gasoline = soup.select_one("a.head.gasoline > div.head_info > span.value").string
# 국내 금
gold = soup.select_one("a.head.gold_domestic > div.head_info > span.value").string
gold

from bs4 import BeautifulSoup
import urllib.request as req
url = "<https://finance.naver.com/marketindex/>" # 시장지표
res = req.urlopen(url) # html 객체
soup = BeautifulSoup(res, "html.parser")
# 미국 달러 환율
usd = soup.select_one("a.head.usd > div.head_info > span.value").string
# 휘발유
gasoline = soup.select_one("a.head.gasoline > div.head_info > span.value").string
# 국내 금
gold = soup.select_one("a.head.gold_domestic > div.head_info > span.value").string
print("미국 달러: {}원".format(usd))
print("휘발유: {}원".format(gasoline))
print("국내 금: {}원".format(gold))
