Parsehub 选择节点语法

Parsehub Selection Node Syntax

我正在尝试使用 parsehub 从网站中提取数据。使用 selection 工具,我能够分离出每个部分的标题 header,但我无法使用 [=] deselect 第二行 header 的第一个单元格33=]。 selection 节点标准发生变化,但实际 selection 没有。 有问题的 HTML 块

    <tr>
    <td width="100%" align="center">
    <table width="493">
    <tr><td></td></tr>
    <tr><td colspan="3">&nbsp;</td></tr>
    <tr bgcolor="#99cc00" height="17">
    <th height="17" colspan="3" title="Scratcher Name"><div align="center"   class="txt_white_bold">LUCKY 7`S #348</div></th>
  </tr>


<tr bgcolor="#99cc00" height="17">
    <th height="17"><div align="center" class="txt_white_bold">Prize Amount</div></th>
    <th align="right"><div align="center" class="txt_white_bold">Prizes Remaining</div></th>
    <th align="right"><div align="center" class="txt_white_bold">Total Prizes</div></th>
  </tr>

选择节点代码如下 选择 1

 {
      "op": "select",
      "tag": "TR",
      "allDescendants": true,
      "flags": [
        {
          "position": 4
        }
      ]
    }

选择 2

{
  "op": "select",
  "tag": "TH",
  "position": 1
}

选择 3

 {
      "op": "select",
      "tag": "DIV",
      "classes": [
        "txt_white_bold"
      ],
      "position": 1
    }

当前输出为

{
"selection1":[
{
"extract1":"LUCKY 7`S #348"
},
{
"extract1":"Prize Amount"
},

等等..我怎么只select "Scratcher Name"而不是"Prize Amount"?

我的第一个想法是将 TH 中标题为 "Scratcher Name" 的项目 'Selection 3' 更改为 select,但我没有成功地正确编码。

ParseHub 的学习算法尚未考虑所有属性,因此在某些(相当罕见的)情况下,它不会达到您的预期。在这种情况下,您始终可以使用 css 或 xpath select 或手动 select 您想要的元素。

这样做:

  1. 任意select离子
  2. 点击节点详情中的绿色编辑按钮
  3. 删除除一个以外的所有文本区域
  4. 将剩余文本区域中的json替换为

    { "op": "cssSelect", "selector": "th[title='Scratcher Name'] div.txt_white_bold", "allDescendants": true }

如果您想改用 xpath,也可以使用 xpathSelect。