terminal에서
pip install requests beautifulsoup4
또는
pip3 install requests beautifulsoup4
으로 requests와 beautifulsoup4 패키지를 설치해주세요
from urllib.request import urlopen from bs4 import BeautifulSoup
html = urlopen("http://www.naver.com")
bsObject = BeautifulSoup(html, "html.parser")
네이버 웹문서를 파싱하는 것이기 때문에 html.parser
를 인자로 전달합니다.
print(bsObject)
import ssl ssl._create_default_https_context = ssl._create_unverified_context
를 추가해줍니다!
from urllib.request import urlopen from bs4 import BeautifulSoup import ssl ssl._create_default_https_context = ssl._create_unverified_context html = urlopen("http://www.naver.com") bsObject = BeautifulSoup(html, "html.parser") print(bsObject)
https://webnautes.tistory.com/779
https://minimin2.tistory.com/138