以下是使用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)

输出:

三亚学院人文与传播学院举办“海上丝路与文化传承”主题讲座
使用requests库和XPATH获取新闻标题httprenwensanyaueducnarticle14192html是三亚学院人文与传播学院新闻地址现在需要获取该链接的新闻标题。请完成程序。

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

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