[Python크롤링] 1. 웹 크롤링의 이해와 BeautifulSoup 설치하기
크롤링이란?
- 웹페이지에서 필요한 데이터를 추출해 내는 작업
BeautifulSoup이란?
- 웹에 있는 데이터를 가져와서 추출할 경우 사용하는 외부 라이브러리로 추가 설치가 필요하다.
BeautifulSoup 설치
- 현재 설치된 모듈 리스트 확인
pip list
- BeautifulSoup 설치
pip3 install BeautifulSoup4
- requests 설치
pip3 install requests
## web01.py
import urllib.request
from bs4 import BeautifulSoup
page = urllib.request.urlopen('http://www.google.com')
## 검색이 용이한 soup객체를 생성합니다.
soup = BeautifulSoup(page, 'html.parser')
## <td>태그를 검색한다.
print(soup.find_all('td'))