可以提取 html element 底下的所有 tag 中的元素的text() 并且帮你拼起来, 这样就不需要用正则先清理一遍标签了。
import requests
r = requests.get("https://kns.cnki.net/KCMS/detail/detail.aspx?dbcode=CJFQ&dbn
response = r.content.decode()
html = etree.HTML(response)
title = html.xpath("//*[@class='h']")[0]
title_str = title.xpath('string(.)') # 这个是需要指明用第几个的
# title_str2 = title.xpath('string(.)').extract() 不合法的方法
title_str3 = html.xpath("string(//*[@class='h'])") # 这个是固定只选第一个
print("Done")
# title_str4 = html.xpath("string(//h2[@class='title'])").extract() 这个方法也不合法