以下是使用 Python 的 requests 库和 XPATH 获取新闻标题的示例代码:

import requests
from lxml import etree

url = 'http://renwen.sanyau.edu.cn/?article/14192.html'

response = requests.get(url)
html = etree.HTML(response.text)

title = html.xpath('//h1[@class='title']/text()')[0]

print(title)

输出结果为:

学院召开第六届教代会第二次会议

原文地址: https://www.cveoy.top/t/topic/oBqP 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录