Python-Library/Python-Library__BeautifulSoup

beautifulsoup 특정 태그 안의 속성값 가져오기

말하는감자 2020. 2. 2. 22:20

아는 동생이 물어봐서 ..

title의 속성값 가져오기!

from bs4 import BeautifulSoup

text = '<img rel="0" src="https://img.jpg" class="btn" alt="Red" title="" width="100" height="100" btn-title="Red">'
soup = BeautifulSoup(text, 'html.parser')

tag = soup.select('img')[0]['btn-title']
print(tag)

'Python-Library > Python-Library__BeautifulSoup' 카테고리의 다른 글

beautifulsoup req  (0) 2018.12.24
selector  (0) 2018.12.24