본문 바로가기
Programing Language/Python

[Python] beautifulsoup에서 HTML 가져오기

by pcm9881 2023. 6. 16.
import requests
from bs4 import BeautifulSoup

req = requests.get('URL')
html = req.text
soup = BeautifulSoup(html, "html.parser")
soup.prettify()

 

 

참조

[stackoverflow]: https://stackoverflow.com/questions/25729589/how-to-get-html-from-a-beautiful-soup-object

 

How to get HTML from a beautiful soup object

I have the following bs4 object listing: >>> listing <div class="listingHeader"> <h2> .... >>> type(listing) <class 'bs4.element.Tag'> I want to extract the raw

stackoverflow.com

 

728x90

댓글