【发布时间】:2020-10-04 23:48:30
【问题描述】:
我正在抓取并且无法获取位于包含“type2”类的另一个“th”元素之前的“th”标签元素。我更喜欢通过识别它是“type2”类的“th”之前的元素“th”来接受它,因为我的 HTML 有很多“th”,这是我在表格之间发现的唯一区别。
使用 rvest 或 xml2(或其他 R 包),我可以获得这个父级吗? 我想要的内容是“text_that_I_want”。
谢谢!
<tr>
<th class="array">text_that_I_want</th>
<td class="array">
<table>
<thead>
<tr>
<th class="string type2">name</th>
<th class="array type2">answers</th>
</tr>
</thead>
【问题讨论】:
-
这是来自可公开查看的网页吗?
标签: html r web-scraping rvest xml2