Python爬虫:使用requests和BeautifulSoup获取新闻标题
以下是使用Python代码实现:
import requests
from bs4 import BeautifulSoup
url = 'http://renwen.sanyau.edu.cn/?article/14280.html'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
title = soup.find('h1', class_='article_title').text.strip()
print(title)
运行结果:
三亚市文化艺术学校2021年春季学期开学典礼隆重举行
原文地址: https://www.cveoy.top/t/topic/oBq7 著作权归作者所有。请勿转载和采集!