Python을 이용한 웹크롤링 - (1)

devyums·2022년 3월 16일
0

< 웹크롤링 기본 환경 설정 >

기존에 Python이 설치된 상태로, Jupyter Notebook에서 기본 환경을 설정했습니다.

1. 라이브러리 설치

beautifulsoup4, selenium, webdriver-manager, openyxl, requests 설치(모듈 사용 시에 설치가 필요한 부분은 부가적인 설치가 필요)

# beautifulsoup4 설치, 웹페이지를 정적으로 크롤링할 경우에 활용
pip install requests beautifulsoup4

# selenium 설치, 가상 브라우저를 활용하여 크롤링을 진행
pip install selenium

# webdriver-manager 설치, 브라우저 매니저, 버전 문제로 인해 활용
pip install webdriver-manager

# openpyxl, requests 설치, 엑셀 함수 자동화 기능
pip install openpyxl
pip install requests

2. 사용하고자 하는 모듈 및 라이브러리를 import

# 파일 데이터를 처리하기 위해 사용되는 모듈
import os
# 시간 데이터를 처리하기 위해 사용되는 모듈
import time
# 데이터 분석 pandas 모듈
import pandas as pd

# selenium 사용
from selenium.webdriver.common.by import By # 태그 존재 여부 확인 가능
from selenium.webdriver.support.ui import WebDriverWait   # 해당 태그를 기다림
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException    # 태그가 없는 예외 처리
from selenium.webdriver.support.ui import Select # 드롭 다운 메뉴값을 선택

# beautifulsoup4 사용
from bs4 import BeautifulSoup

# 항상 최신버전의 chromedriver를 자동으로 사용할 수 있도록 하는 라이브러리
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

# 엑셀 함수 작업 자동화
import openpyxl as op
import requests

# 크롤링한 이미지를 저장하기 위해 사용되는 모듈
import urllib.request

0개의 댓글

관련 채용 정보