Diff
checker
Text
Text
Images
Documents
Excel
Folders
Legal
Enterprise
Desktop
Pricing
Sign in
Download Diffchecker Desktop
Compare text
Find the difference between two text files
Tools
History
Real-time editor
Hide unchanged lines
Disable line wrap
Layout
Split
Unified
Diff precision
Smart
Word
Char
Syntax highlighting
Choose syntax
Ignore
Transform text
Go to first change
Edit input
Diffchecker Desktop
The most secure way to run Diffchecker. Get the Diffchecker Desktop app: your diffs never leave your computer!
Get Desktop
3주차 과제 비교
Created
4 years ago
Diff never expires
Clear
Export
Share
Explain
12 removals
Lines
Total
Removed
Characters
Total
Removed
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
15 lines
Copy
25 additions
Lines
Total
Added
Characters
Total
Added
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
29 lines
Copy
Copy
Copied
Copy
Copied
## 웹 크롤링에 필요한 세팅: requests와 bs4 패키지
import requests
import requests
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup
Copy
Copied
Copy
Copied
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)
Copy
Copied
Copy
Copied
soup = BeautifulSoup(data.text, 'html.parser')
soup = BeautifulSoup(data.text, 'html.parser')
Copy
Copied
Copy
Copied
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
Copy
Copied
Copy
Copied
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)
Copy
Copied
Copy
Copied
Saved diffs
Original text
Open 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)
Changed text
Open 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)
Find difference