[python] 웹페이지 html 파싱

1. 설명

- requests, BeautifulSoup 패키지를 이용하여 특정 웹페이지 html 파싱

- 파싱(Parsing) : 구문 분석


2. 사전 필요

- 파싱할 웹페이지(예 : https://blog.hkand.com)


3. 코드

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import requests
 
from bs4 import BeautifulSoup
 
url = "https://blog.hkand.com"
 
webpage = requests.get(url)
 
soup = BeautifulSoup(webpage.content, "html.parser")
 
print(soup)


4. 기타

- [구글 코랩] https://blog.hkand.com/2023/01/blog-post.html


끝.