Diff
checker
Testo
Testo
Immagini
Documenti
Excel
Cartelle
Legal
Enterprise
Applicazione per desktop
Prezzi
Accedi
Scarica Diffchecker Desktop
Confronta il testo
Trova la differenza tra due file di testo
Strumenti
Cronologia
Editor live
Comprimi invariate
Senza a capo
Layout
Diviso
Unificato
Livello di dettaglio
Intelligente
Parola
Carattere
Evidenziazione sintassi
Scegli sintassi
Ignora
Trasforma testo
Vai alla prima modifica
Modifica input
Diffchecker Desktop
Il modo più sicuro per usare Diffchecker. Ottieni l'app Diffchecker Desktop: i tuoi diff non lasciano mai il tuo computer!
Ottieni Desktop
3주차 과제 비교
Creato
4 anni fa
Il diff non scade mai
Eliminare
Esporta
Condividere
Spiegare
12 rimozioni
Linee
Totale
Rimosso
Caratteri
Totale
Rimosso
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
15 linee
Copia tutti
25 aggiunte
Linee
Totale
Aggiunto
Caratteri
Totale
Aggiunto
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
29 linee
Copia tutti
Copia
Copiato
Copia
Copiato
## 웹 크롤링에 필요한 세팅: requests와 bs4 패키지
import requests
import requests
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup
Copia
Copiato
Copia
Copiato
headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}
headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}
data = requests.get('https://www.genie.co.kr/chart/top200?ditc=M&rtm=N&ymd=20210701',headers=headers)
data = requests.get('https://www.genie.co.kr/chart/top200?ditc=M&rtm=N&ymd=20210701',headers=headers)
Copia
Copiato
Copia
Copiato
soup = BeautifulSoup(data.text, 'html.parser')
soup = BeautifulSoup(data.text, 'html.parser')
Copia
Copiato
Copia
Copiato
trs = soup.select('
#body-content > div.newest-list > div > table > tbody > tr
')
## 지니뮤직의 1~50위 곡의 순위/곡명/가수를 스크래핑해보자
# 순위
#body-content > div.newest-list > div > table > tbody > tr:nth-child(1) > td.number
# 곡명
#body-content > div.newest-list > div > table > tbody > tr:nth-child(1) > td.info > a.title.ellipsis
# 가수
#body-content > div.newest-list > div > table > tbody > tr:nth-child(1) > td.info > a.artist.ellipsis
# 공통부분:
#body-content > div.newest-list > div > table > tbody > tr
Copia
Copiato
Copia
Copiato
for tr in trs:
title = tr.select_one('
td.info > a.title.ellipsis
'
).text.strip()
# 최종 정리:
rank = tr.select_one('td.number').text[0:2].strip()
musics = list(soup.select("#body-content > div.newest-list > div > table > tbody > tr"))
artist =
tr
.select_one(
'
td.info > a.artist.ellipsis
'
).text
for music in musics:
rank = music.select_one("td.number").text[:2].replace('\n', ' ')
title = music.select_one("
td.info > a.title.ellipsis
"
).text.strip()
artist =
music
.select_one(
"
td.info > a.artist.ellipsis
"
).text
.strip()
print(rank, title, artist)
print(rank, title, artist)
Copia
Copiato
Copia
Copiato
Diff salvati
Testo originale
Apri file
import requests from bs4 import BeautifulSoup headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'} data = requests.get('https://www.genie.co.kr/chart/top200?ditc=M&rtm=N&ymd=20210701',headers=headers) soup = BeautifulSoup(data.text, 'html.parser') trs = soup.select('#body-content > div.newest-list > div > table > tbody > tr') for tr in trs: title = tr.select_one('td.info > a.title.ellipsis').text.strip() rank = tr.select_one('td.number').text[0:2].strip() artist = tr.select_one('td.info > a.artist.ellipsis').text print(rank, title, artist)
Testo modificato
Apri file
## 웹 크롤링에 필요한 세팅: requests와 bs4 패키지 import requests from bs4 import BeautifulSoup headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'} data = requests.get('https://www.genie.co.kr/chart/top200?ditc=M&rtm=N&ymd=20210701',headers=headers) soup = BeautifulSoup(data.text, 'html.parser') ## 지니뮤직의 1~50위 곡의 순위/곡명/가수를 스크래핑해보자 # 순위 #body-content > div.newest-list > div > table > tbody > tr:nth-child(1) > td.number # 곡명 #body-content > div.newest-list > div > table > tbody > tr:nth-child(1) > td.info > a.title.ellipsis # 가수 #body-content > div.newest-list > div > table > tbody > tr:nth-child(1) > td.info > a.artist.ellipsis # 공통부분: #body-content > div.newest-list > div > table > tbody > tr # 최종 정리: musics = list(soup.select("#body-content > div.newest-list > div > table > tbody > tr")) for music in musics: rank = music.select_one("td.number").text[:2].replace('\n', ' ') title = music.select_one("td.info > a.title.ellipsis").text.strip() artist = music.select_one("td.info > a.artist.ellipsis").text.strip() print(rank, title, artist)
Trovare la differenza