好的,以下是使用Python爬取百度新闻标题的代码示例:
import requests
from bs4 import BeautifulSoup
url ="https://news.baidu.com/"
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
titles = soup.select("div#pane-news ul li a")
for title in titles:
print(title.get_text())
这段代码首