Hỏi & Đáp
import requests from bs4 import BeautifulSoup res = requests.get(' https://v.daum.net/v/20170615203441266 ') soup = BeautifulSoup(res.content, 'html.parser') items = soup.select (' div.news _view.fs_type1 > div.article_view > section > p:nth-child(1)') for item in items: print (item.get_text()) items = soup.select (' div.news _view.fs_type1 > div.article_view > section > p:nth-child(2)') for item in items: print (item.get_text()) items = soup.select (' div.news _view.fs_type1 > div.article_view > section > p:nth-child(3)') for item in items: print (item.get_text()) items = soup.select (' div.news _view.fs_type1 > div.article_view > section > p:nth-child(4)') for item in items: print (item.get_text()) 다다음 강의에 css selector로 해보다가 비슷하게 방법을 찾았어요 1-4 까지 반복되는걸 좀 편하게 바꾸고 싶은데 아직 공부가 부족한지 자꾸 오류가 나네요 ㅠㅠ 앞으로는 모르는 내용있으면 다음 강의를 좀 들어볼게요 ㅎㅎ 감사합니다
- Lượt thích
- 0
- Số bình luận
- 2
- Lượt xem
- 582
Hỏi & Đáp
import requests from bs4 import BeautifulSoup res = requests.get(' https://v.daum.net/v/20170615203441266 ') soup = BeautifulSoup(res.content, 'html.parser') items = soup.select (' div.news _view.fs_type1 > div.article_view > section > p:nth-child(1)') for item in items: print (item.get_text()) items = soup.select (' div.news _view.fs_type1 > div.article_view > section > p:nth-child(2)') for item in items: print (item.get_text()) items = soup.select (' div.news _view.fs_type1 > div.article_view > section > p:nth-child(3)') for item in items: print (item.get_text()) items = soup.select (' div.news _view.fs_type1 > div.article_view > section > p:nth-child(4)') for item in items: print (item.get_text()) 다다음 강의에 css selector로 해보다가가 비슷하게 방법을 찾았어요 1-4 까지 반복되는걸 좀 편하게 바꾸고 싶은데 아직 공부가 부족한지 자꾸 오류가 나네요 ㅠㅠ 앞으로는 모르는 내용있으면 다음 강의를 좀 들어볼게요 ㅎㅎ 감사합니다
- Lượt thích
- 0
- Số bình luận
- 2
- Lượt xem
- 610