刮擦如何刮擦复杂的标签

时间:2019-11-05 06:29:38

标签: python scrapy

我一直在尝试刮擦,但仍然无法弄清楚。我只能在excel文件的1列下找到它。有什么愿意帮助我的人吗? html代码和所需结果如下:

HTML代码:

enter image description here

所需结果:

enter image description here

2 个答案:

答案 0 :(得分:0)

使用适当的CSS选择器

  • 首字母缩写:.views-label-acronym
  • 项目:.views-field-title .field-content
  • 研究者:.views-label-xml-researcher .field-content

答案 1 :(得分:0)

您可以通过XPath以更优雅的方式获得所需的结果:

project_acronym = response.xpath('//span[.="Project acronym"]/following-sibling::span[1]/text()').get()
project = response.xpath('//span[.="Project"]/following-sibling::span[1]/text()').get()