# beautifulsoup4 설치 : pip install beautifulsoup4
# lxml 설치 : pip install lxml
# beautifulsoup 참고 사이트 : https://www.crummy.com/software/BeautifulSoup/bs4/doc.ko/
import requests
from bs4 import BeautifulSoup
# url = "https://comic.naver.com/webtoon/weekday.nhn"
url = "https://comic.naver.com/webtoon/list.nhn?titleId=733766&weekday=mon"
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("https://comic.naver.com" + link)
# 만화 제목 + 링크 가져오기
# for cartoon in cartoons:
# title = cartoon.a.get_text()
# link = "https://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))
[파이썬 웹 스크래핑] Beautifulsoup4 (쿠팡 노트북) - 6 (0) | 2020.09.04 |
---|---|
[파이썬 웹 스크래핑] Beautifulsoup4 (쿠팡 노트북) - 5 (0) | 2020.09.03 |
[파이썬 웹 스크래핑] Beautifulsoup4 (네이버 웹툰) - 3 (0) | 2020.09.01 |
[파이썬 웹 스크래핑] Beautifulsoup4 (네이버 웹툰) - 2 (0) | 2020.08.31 |
[파이썬 웹 스크래핑] Beautifulsoup4 (네이버 웹툰) - 1 (0) | 2020.08.29 |
댓글 영역