【发布时间】:2018-11-22 20:04:27
【问题描述】:
我正在尝试使用 scrapy 和 xpath 从网站中提取属性:
response.xpath('//section[@id="attributes"]/div/table/tbody/tr/td/text()').extract()
属性嵌套如下:
<section id="attributes">
<h5>Attributes</h5>
<div>
<table>
<tbody>
<tr>
<td>Attribute 1</td>
<td>Value 1</td>
</tr>
<tr>
<td>Attriburte 2</td>
<td>Value 2</td>
</tr>
与此相关的有两个问题:
- 获取 td 元素的内容(XPath 命令将返回[])
- 检索到
td后,我需要以某种方式进行配对。例如:“属性 1”=“值 1”
我是 phyton 和 scrapy 的新手,非常感谢任何帮助。
【问题讨论】: