GiantStepDEV
article thumbnail

ํŒŒ์ด์ฌ ์„ ์ˆ˜ํ•™์Šต ๋๋‚ธ ํ›„ ๊ฐœ์ธ์ ์œผ๋กœ ๋ญ˜ ํ•ด๋ณผ๊นŒ ๊ณ ๋ฏผํ•˜๋‹ค๊ฐ€ ์ผ์ƒ์ƒํ™œ์—์„œ ํ”ํžˆ ์ ‘ํ•  ์ˆ˜ ์žˆ๊ณ ,

๊ฒฐ๊ณผ๋ฅผ ๋ˆˆ์œผ๋กœ ๋ฐ”๋กœ ๋ณผ ์ˆ˜ ์žˆ๋Š” ํฌ๋กค๋ง์„ ์ด์šฉํ•ด ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค๊ธฐ๋กœ ํ–ˆ๋‹ค.

 

๊ฐœ์ธ์ ์œผ๋กœ ์Œ์› ์ถ”์ถœํ•  ๋•Œ ํฌ๋กค๋ง ๋˜๋Š” ์‚ฌ์ดํŠธ๋ฅผ ์ฐพ๊ธฐ๊ฐ€ ์–ด๋ ค์› ๋‹ค.

(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)

 

์•„๋ฌดํŠผ ๋ฐฐ์šด ๊ฒƒ ํ† ๋Œ€๋กœ ๊ตฌ๊ธ€๋ง ํ•ด๊ฐ€๋ฉฐ ์–ผ๊ธฐ์„ค๊ธฐ ๋งŒ๋“ค์–ด ๋ดค๋Š”๋ฐ ์‹ค์ œ๋กœ ๋™์ž‘ํ•˜๋Š” ๊ฑธ ๋ณด๋‹ˆ ๊ฐํšŒ๊ฐ€ ์ƒˆ๋กœ์› ๋‹ค.

 

๋‚จ๋“ค์ด ๋ดค์„๋•Œ ๋ญ ์ €๊ฑฐ ํ•ด๋†“๊ณ  ์ €๋ ‡๊ฒŒ ๊ธฐ๋ปํ•˜๋ƒ ํ• ํ…๋ฐ..(๋จธ์“ฑ)

profile

GiantStepDEV

@kongmi

ํฌ์ŠคํŒ…์ด ์ข‹์•˜๋‹ค๋ฉด "์ข‹์•„์š”โค๏ธ" ๋˜๋Š” "๊ตฌ๋…๐Ÿ‘๐Ÿป" ํ•ด์ฃผ์„ธ์š”!