"뷰티플 수프"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-<source +<syntaxhighlight , -</source> +</syntaxhighlight>))
7번째 줄: 7번째 줄:
[[파일:bs4-doc-image-6.1.jpg]]
[[파일:bs4-doc-image-6.1.jpg]]


<source lang='python'>
<syntaxhighlight lang='python'>
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup
from urllib.request import urlopen
from urllib.request import urlopen
15번째 줄: 15번째 줄:
     for anchor in soup.find_all('a'):
     for anchor in soup.find_all('a'):
         print(anchor.get('href', '/'))
         print(anchor.get('href', '/'))
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2021년 6월 5일 (토) 19:45 판

1 개요

Beautiful Soup
뷰티풀 수프
  • HTML과 XML 문서를 파싱하는 파이썬 패키지
  • 잘못 쓴 태그, 안닫힌 태그 등 소위 '태그 수프'를 잘 처리할 수 있다.

Bs4-doc-image-6.1.jpg

from bs4 import BeautifulSoup
from urllib.request import urlopen

with urlopen('https://en.wikipedia.org/wiki/Main_Page') as response:
    soup = BeautifulSoup(response, 'html.parser')
    for anchor in soup.find_all('a'):
        print(anchor.get('href', '/'))

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}