파이선 코드를 짜야하는데..

파이선 코드를 짜야하는데..

작성일 2024.04.19댓글 1건
    게시물 수정 , 삭제는 로그인 필요

네이버 웹툰에서 저자랑.별점이랑.제목이 상위50개 정렬해서 나오도록 웹스크렙핑을통해 코드를 짜야하는데 도저히 안되네요
급해요 좀알려주세요



profile_image 익명 작성일 -

import requests from bs4 import BeautifulSoup # 웹툰 URL url = "https://comic.naver.com/webtoon/weekdayList.nhn?week=thu" # 웹페이지 요청 response = requests.get(url) # HTML 파싱 soup = BeautifulSoup(response.text, "html.parser") # 제목, 저자, 별점 추출 webtoons = [] for webtoon in soup.select("div.thumb"): title = webtoon.select_one("dt a").text author = webtoon.select_one("dd.desc_atist").text rating = webtoon.select_one("div.rating_type strong").text webtoons.append((title, author, float(rating))) # 별점 순 정렬 sorted_webtoons = sorted(webtoons, key=lambda x: x[2], reverse=True) # 상위 50개 출력 for webtoon in sorted_webtoons[:50]: print(f"제목: {webtoon[0]}, 저자: {webtoon[1]}, 별점: {webtoon[2]}")

파이선 문자열 합

s='1.23,2.4,3.123' 라는 문자열에서 1.23+2.4+3.123이 되는 코드를 짜야하는데 어떻게 짜야하나요? s = '1.23,2.4,3.123' vals = [*map(float, s.split...