Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- db네이밍규칙
- 자기계발회고
- 데이터베이스네이밍규칙
- 장고
- 파이썬
- db설계핵심요약
- getpost
- Python
- 포링키
- 팀스파르타
- spring필수문법
- 데이터베이스설계요약
- django
- 프라이머리키
- 스파르타코딩
- jpa플러시
- 리콰이어먼츠 설정
- 패스트캠퍼스
- 내일배움캠프
- 겟메핑
- JPA
- db설계방법
- 스파르타코딩클럽
- 코딩
- dbnamingrule
- 릴레이션십데이터베이스
- db설계과정
- tableperclass
- 포스트메핑
- jakartapersistenceapi
Archives
- Today
- Total
당우 일기장
지니뮤직 크롤링 하기 본문
파이썬을 이용해 지니뮤직 차트를 크롤링해 보았습니다
탑 50까지의 순위를 크롤링했습니다
import requests
from bs4 import BeautifulSoup
from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.dbsparta
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',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)
