2020/09/25

    [Python] web scraping

    [Python] web scraping

    BeautifulSoup 라이브러리를 사용하면 간단하게 web scraping을 할 수 있다. BeautifulSoup 라이브러리는 HTML, XML을 분석해준다. 웹 사이트의 html을 scraping하기 위해서는 urllib 라이브러리도 함께 사용해야한다. 두 라이브러리를 함께 사용하여 웹 사이트의 html을 scraping할 수 있다. urllib option import urllib.request as request url = "https://990427.tistory.com" data = request.urlopen(url) urlopen() 함수는 url에 해당하는 웹 데이터를 가져온다. BeautifulSoup option from bs4 import BeautifulSoup html = '..