我正在使用 scrapy 从特定 <td>
内的网站中抓取内容标签。本教程向我展示了如何下载所有数据——我只想要 <td>
中的数据。 。停下来!
示例通用表代码:
<table>
<tr>
<td>1,1</td>
<td>1,2</td>
</tr>
<tr>
<td>2,1</td>
<td>2,2</td>
</tr>
</table>
我不知道如何获取 2,2
值。
提前致谢
最佳答案
使用 response.xpath()
或 response.css()
快捷方式获取 table 中的最后一个
。示例:td
元素
response.xpath("//table//td[last()]/text()").extract_first()
response.xpath("//table//td/text()").extract()[-1]
response.css("table td::text").extract()[-1]
关于python - 使用 scrapy 抓取特定的表格元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36670918/