# -*- coding:utf8 -*-
import requests
import lxml.html

# 获取html内容中的a链接与内容
chapters_url = "http://www.civil.tsinghua.edu.cn/ce/83.html"
html = requests.get(chapters_url).content
selector = lxml.html.fromstring(html)
res = selector.xpath("///a/text()")
res1 = selector.xpath("///a/@href")
# print(res)
# print(res1)

for i,s in enumerate(res):
    print(res1[i])
    print(s)

  

相关文章:

  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2021-11-29
  • 2022-01-02
  • 2022-12-23
  • 2021-09-10
猜你喜欢
  • 2021-09-11
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
相关资源
相似解决方案