-1
단락 태그의 내용을 가져 오는 데 약간 혼란 스럽습니다.단락 내용 가져 오기
<div class="SomeID">
<p>What a voice! </p>
</div>
나는이 시점
list = soup.find_all("div","SomeID")
하지만 어떻게 단락 콘텐츠를하기에 이르렀다. (무슨 소리!)
이기본적인 문제는 모든 단락 태그의 내용에서 얻는 것입니다
import urllib
from bs4 import BeautifulSoup
html = urllib.urlopen('http://www.dawn.com/news/1267272/democracys-woes').read()
soup = BeautifulSoup(html, 'html.parser')
list = soup.find_all("div","comment__body cf")
print list
둘 다 작동하지 않습니다. 질문을 업데이트 중입니다. 친절하게 그것의 간단한 개요를 가져 가라. –
@AliMurtaza 음,'div.comment__body> p'는 나를 위해 일합니다. – alecxe
그것은 작동하지 않습니다 : 가져 오기를 URLLIB BS4 수입 BeautifulSoup로에서 HTML = urllib.urlopen ('http://www.dawn.com/news/1267272/democracys-woes') .read()를 수프 = BeautifulSoup로 (html, 'html.parser') # 목록 = soup.find_all ("div", "comment__body cf") # 인쇄 목록 list2 = soup.select_one ("div.comment__body cf> p"). get_text strip = True) 인쇄 목록 2 –