-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8_bs4_gauss.py
More file actions
29 lines (25 loc) · 877 Bytes
/
Copy path8_bs4_gauss.py
File metadata and controls
29 lines (25 loc) · 877 Bytes
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
import requests
from bs4 import BeautifulSoup
url = "http://comic.naver.com/webtoon/list.nhn?titleId=675554"
res = requests.get(url)
res.raise_for_status()
soup = BeautifulSoup(res.text, "lxml")
# cartoons = soup.find_all("td", attrs={"class": "title"})
# title = cartoons[0].a.get_text()
# link = cartoons[0].a["href"]
# print(title)
# print("http://comic.naver.com" + link)
# 웹툰 제목 + 링크 가져오기
# for cartoon in cartoons:
# title = cartoon.a.get_text()
# link = "http://comic.naver.com" + cartoon.a["href"]
# print(title, link)
# 웹툰 평점 구하기
total_rates = 0
cartoons = soup.find_all("div", attrs={"class": "rating_type"})
for cartoon in cartoons:
rate = cartoon.find("strong").get_text()
print(rate)
total_rates += float(rate)
print("전체 점수 : ", total_rates)
print("평균 점수 : ", total_rates / len(cartoons))