url ='https://n.news.naver.com/mnews/article/015/0004716773?sid=105'
# 서버에게 브라우저로 접속했다라는 것을 인지시키기 위한 헤더
header = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36'}
res = req.get(url, headers=header).text
html = bs(res, 'lxml')
new_title = html.select_one('h2.media_end_head_headline')
new_content = html.select_one('div#dic_area')
print('제목', new_title.text)
print('내용', new_content.text.strip())
728x90
반응형
'크롤링' 카테고리의 다른 글
크롤링_네이버 영화 리뷰 수집(실습) (0) | 2022.06.28 |
---|---|
크롤링_영화 이름 및 평점 수집(실습) (0) | 2022.06.28 |
크롤링_멜론 음원 차트 수집(실습) (0) | 2022.06.27 |
크롤링_beautifulSoup (0) | 2022.06.27 |
크롤링_requests (0) | 2022.06.27 |