📌  相关文章
📜  从特定的 p 标签中抓取文本 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:14.028000             🧑  作者: Mango

代码示例1
from bs4 import BeautifulSoup
import urllib

url = urllib.urlopen('http://meinparlament.diepresse.com/')
content = url.read()
soup = BeautifulSoup(content, 'lxml')

table = soup.findAll('div',attrs={"class":"content-question"})
for x in table:
    print x.find('p').text

# Another way to retrieve tables:
# table = soup.select('div[class="content-question"]')