以下是使用Python的requests库和lxml库的代码:

import requests
from lxml import etree

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

response = requests.get(url)
html = response.content.decode('utf-8')
selector = etree.HTML(html)

title = selector.xpath('//div[@class='article-heading']/h1/text()')[0]

print(title)

输出:

三亚学院人文与传播学院举办'海上丝路与文化传承'主题讲座
Python爬取三亚学院人文与传播学院新闻标题

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

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