ํ์ด์ฌ ์ ์ํ์ต ๋๋ธ ํ ๊ฐ์ธ์ ์ผ๋ก ๋ญ ํด๋ณผ๊น ๊ณ ๋ฏผํ๋ค๊ฐ ์ผ์์ํ์์ ํํ ์ ํ ์ ์๊ณ ,
๊ฒฐ๊ณผ๋ฅผ ๋์ผ๋ก ๋ฐ๋ก ๋ณผ ์ ์๋ ํฌ๋กค๋ง์ ์ด์ฉํด ํ๋ก๊ทธ๋จ์ ๋ง๋ค๊ธฐ๋ก ํ๋ค.
๊ฐ์ธ์ ์ผ๋ก ์์ ์ถ์ถํ ๋ ํฌ๋กค๋ง ๋๋ ์ฌ์ดํธ๋ฅผ ์ฐพ๊ธฐ๊ฐ ์ด๋ ค์ ๋ค.
(VIBE, MELON, YoutubeMusic ๋ค ์๋๋..)
์ฐพ๋ค๊ฐ ์ถ์ต์ ๋ฒ ์ค์์ ํฌ๋กค๋ง ์ฑ๊ณต!!(๊ฐ์ฌํฉ๋๋ค(?))
import requests
from bs4 import BeautifulSoup
import pandas as pd
import datetime
import os
#ํ์ฌ ์๊ฐ ์๋ด
date = datetime.datetime.now()
now_date = date.strftime('%Y๋
%m์ %d์ผ %H์ %M๋ถ ์
๋๋ค.')
print("ํ์ํฉ๋๋ค, ", now_date)
print("์ค๋์ ์ฃผ์ ์ ๋ณด๋ฅผ ์์ฝํด ๋๋ฆฌ๊ฒ ์ต๋๋ค.")
#์ ๊ตญ ๋ ์จ ์์ฝ(์์ธ,๋๊ตฌ,๋ถ์ฐ)
city = input("1. ๋ ์จ๋ฅผ ์๋ ค๋๋ฆฝ๋๋ค! ์ง์ญ๋ช
์ ์
๋ ฅํ์ธ์. > ")
r = requests.get("https://search.naver.com/search.naver?where=nexearch&sm=top_hty&fbm=0&ie=utf8&query="+city+"+%EB%82%A0%EC%94%A8")
bs = BeautifulSoup(r.text, "html.parser")
temp = bs.select_one("div.temperature_text > strong")
weather = bs.select_one("div.temperature_info > p > span.weather.before_slash")
temp_change = bs.find("p", {"class":"summary"}).text.split()[0:3]
temp_change_result = " ".join(temp_change)
print(f"{city} ๋ ์จ : {temp.text}, {weather.text}, ์ด์ ๋ณด๋ค {temp_change_result}.")
#์ฝ๋ก๋ 19 ํ์ง์ ํํฉ, ์ผ์ผ ํ์ง
c = requests.get("https://search.naver.com/search.naver?where=nexearch&sm=top_sug.pre&fbm=1&acr=2&acq=%EA%B5%AD%EB%82%B4+%EC%BD%94%EB%A1%9C%EB%82%98&qdt=0&ie=utf8&query=%EA%B5%AD%EB%82%B4+%EC%BD%94%EB%A1%9C%EB%82%98+%ED%99%95%EC%A7%84%EC%9E%90+%ED%98%84%ED%99%A9")
bs2 = BeautifulSoup(c.text, "html.parser")
today_covid = bs2.select_one("div.status_info > ul > li > p.info_num")
print("2. ์ฝ๋ก๋ ํ์ง์ ํํฉ ์๋ด๋๋ฆฝ๋๋ค.")
print("์ ๊ตญ ์ ๊ท ํ์ง์ : {}๋ช
".format(today_covid.text))
#์ค๋์ ํซํ ํฝ ํค๋๋ผ์ธ
n = requests.get("https://news.google.com/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNRFZxYUdjU0FtdHZHZ0pMVWlnQVAB?hl=ko&gl=KR&ceid=KR%3Ako")
bs3 = BeautifulSoup(n.text, "html.parser")
titles = bs3.find_all("h4")[0:10]
print("3. ์ค๋์ ์ฃผ์ ๋ด์ค")
for i in titles:
print("-",i.get_text())
#์ค๋์ ์์ ์ข
ํฉ TOP10!!
print("4. ์ค๋์ ์์ ์ข
ํฉ TOP10")
m = requests.get("https://music.bugs.co.kr/chart/track/day/total")
bs4 = BeautifulSoup(m.text, "html.parser")
today_artist = []
today_title = []
artist = bs4.find_all("p", {"class":"artist"})
title = bs4.find_all("p", {"class":"title"})
for a in range(len(artist)):
today_artist.append(artist[a].text)
for t in range(len(title)):
today_title.append(title[t].text)
today_artist = list(map(lambda s : s.strip(), today_artist))
today_title = list(map(lambda s : s.strip(), today_title))
for c in range(0,10):
print(f"{c+1}์ : {today_artist[c]} - {today_title[c]}")
์๋๋ ์คํ ํ๋ฉด์ด๋ค.
์ ๋ง ๋ด์ง์ค๊ฐ ๋์ธ์ด๊ธด ํ๊ฐ๋ณด๋ค.
๊ฐ์ธ์ ์ผ๋ก ๋ฅด์ธ๋ผํ๊ณผ ๋ด์ง์ค๋ฅผ ์ข์ํ๋๋ฐ 10์ ์์ ๋ค ์๋๊ฑธ ๋ณด๋ ํ๋ญ(TMI)
์๋ฌดํผ ๋ฐฐ์ด ๊ฒ ํ ๋๋ก ๊ตฌ๊ธ๋ง ํด๊ฐ๋ฉฐ ์ผ๊ธฐ์ค๊ธฐ ๋ง๋ค์ด ๋ดค๋๋ฐ ์ค์ ๋ก ๋์ํ๋ ๊ฑธ ๋ณด๋ ๊ฐํ๊ฐ ์๋ก์ ๋ค.
๋จ๋ค์ด ๋ดค์๋ ๋ญ ์ ๊ฑฐ ํด๋๊ณ ์ ๋ ๊ฒ ๊ธฐ๋ปํ๋ ํ ํ ๋ฐ..(๋จธ์ฑ)
'๐ฉโ๐ป Language > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ํ์ด์ฌ(Python) - pygame ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ด์ฉํด Pong! ๊ฒ์ ๋ง๋ค๊ธฐ (4) | 2023.02.01 |
---|