<!DOCTYPE html>
<html>
<head>
<title>This is a title</title>
</head>
<body>
<div>
<p>Hello world!</p>
</div>
</body>
</html>
위의 대표 라이브러리를 사용하여 아래와 같이 크롤링을 할 수 있다!
import requests
from bs4 import BrautifulSoup
res = requests.get("크롤링할 주소")
print(res.content)
soup = BeautifulSoup(res.content, 'html.parser')
# html.parser는 위에서 가지고 온 html파일을 컴퓨터가 알아들을 수 있도록 잘라주는(구조화 시켜주는) 기능
title = soup.find('title')
# parsing한 값에서 title을 찾아서 저장
print(title.get_text())
# 찾은 title에서 text값을 출력