【发布时间】:2020-10-01 02:18:56
【问题描述】:
我只想在 python 中获取 page <h1>This is Title</h1> 的标题。
我尝试了一些方法,但没有得到想要的结果。
import requests
from bs4 import BeautifulSoup
response = requests.get("https://www.strawpoll.me/20321563/r")
html_content = response.content
soup = BeautifulSoup(html_content, "html.parser")
for i in soup.get_text("p", {"class": "result-list"}):
print(i)
【问题讨论】:
标签: html python-3.x html-parsing