import requests
from lxml import etree
doMian = "https://www.jkskr.com"
req = requests.get(doMian)
req.encoding = 'utf-8'
myStr = req.text
# 利用xpath解析最新新闻的所有列表信息
myHtml = etree.HTML(myStr)
res = myHtml.xpath("//div[@class='web-content']")[1]
# print(res)
# for item in res: //多个就用循环
# ./表示相对搜索,//表示全局搜索/*/表示任意的元素
print(res.xpath(".//a//div[@class='web-news-title']/text()")) # 获取文本
print(res.xpath(".//a/@href")) # 获取href属性