代码相同,可只有一组能抓到数据,另一组就什么都抓不到

不屈的灵魂 6天前 49

arrayData = UiElement.DataScrap({"html":[{"id":"op-cc-macroscopic-monitor-item-rank-table","tag":"DIV"}],"wnd":[{"app":"chrome","cls":"Chrome_WidgetWin_1","title":"*"},{"cls":"Chrome_RenderWidgetHostHWND","title":"Chrome Legacy Window"}]},{"Columns":[{"props":["text"],"selecors":[{"className":"oui-card-content","index":0,"prefix":"","tag":"div","value":"div.oui-card-content"},{"className":"contentContainer","index":0,"prefix":">","tag":"div","value":"div.contentContainer"},{"className":"oui-table-wrapper","index":0,"prefix":">","tag":"div","value":"div.oui-table-wrapper"},{"className":"ant-table-wrapper oui-table oui-table-b3af-72ac-b86d","index":0,"prefix":">","tag":"div","value":"div.ant-table-wrapper.oui-table.oui-table-b3af-72ac-b86d"},{"className":"ant-spin-nested-loading","index":0,"prefix":">","tag":"div","value":"div.ant-spin-nested-loading"},{"className":"ant-spin-container","index":0,"prefix":">","tag":"div","value":"div.ant-spin-container"},{"className":"ant-table ant-table-default ant-table-scroll-position-left","index":0,"prefix":">","tag":"div","value":"div.ant-table.ant-table-default.ant-table-scroll-position-left"},{"className":"ant-table-content","index":0,"prefix":">","tag":"div","value":"div.ant-table-content"},{"className":"ant-table-body","index":0,"prefix":">","tag":"div","value":"div.ant-table-body"},{"className":"","index":0,"prefix":">","tag":"table","value":"table"},{"className":"ant-table-tbody","index":0,"prefix":">","tag":"tbody","value":"tbody.ant-table-tbody"},{"className":"ant-table-row oui-table-row-tree-node-1 ant-table-row-level-0","index":0,"prefix":">","tag":"tr","value":"tr.ant-table-row.oui-table-row-tree-node-1.ant-table-row-level-0"},{"index":0,"prefix":">","tag":"td","value":"td"},{"index":0,"prefix":">","tag":"div","value":"div"},{"className":"alife-dt-card-common-table-sortable-value","index":0,"prefix":">","tag":"span","value":"span.alife-dt-card-common-table-sortable-value"}]}],"ExtractTable":0},{"objNextLinkElement":"","iMaxNumberOfPage":5,"iMaxNumberOfResult":-1,"iDelayBetweenMS":1000,"bContinueOnError":false})
arrayData = UiElement.DataScrap({"html":[{"id":"op-cc-macroscopic-monitor-item-rank-table","tag":"DIV"}],"wnd":[{"app":"chrome","cls":"Chrome_WidgetWin_1","title":"*"},{"cls":"Chrome_RenderWidgetHostHWND","title":"Chrome Legacy Window"}]},{"Columns":[{"props":["text"],"selecors":[{"className":"oui-card-content","index":0,"prefix":"","tag":"div","value":"div.oui-card-content"},{"className":"contentContainer","index":0,"prefix":">","tag":"div","value":"div.contentContainer"},{"className":"oui-table-wrapper","index":0,"prefix":">","tag":"div","value":"div.oui-table-wrapper"},{"className":"ant-table-wrapper oui-table oui-table-5231-d20f-d5fb","index":0,"prefix":">","tag":"div","value":"div.ant-table-wrapper.oui-table.oui-table-5231-d20f-d5fb"},{"className":"ant-spin-nested-loading","index":0,"prefix":">","tag":"div","value":"div.ant-spin-nested-loading"},{"className":"ant-spin-container","index":0,"prefix":">","tag":"div","value":"div.ant-spin-container"},{"className":"ant-table ant-table-default ant-table-scroll-position-left","index":0,"prefix":">","tag":"div","value":"div.ant-table.ant-table-default.ant-table-scroll-position-left"},{"className":"ant-table-content","index":0,"prefix":">","tag":"div","value":"div.ant-table-content"},{"className":"ant-table-body","index":0,"prefix":">","tag":"div","value":"div.ant-table-body"},{"className":"","index":0,"prefix":">","tag":"table","value":"table"},{"className":"ant-table-tbody","index":0,"prefix":">","tag":"tbody","value":"tbody.ant-table-tbody"},{"className":"ant-table-row oui-table-row-tree-node-1 ant-table-row-level-0","index":0,"prefix":">","tag":"tr","value":"tr.ant-table-row.oui-table-row-tree-node-1.ant-table-row-level-0"},{"index":0,"prefix":">","tag":"td","value":"td"},{"index":0,"prefix":">","tag":"div","value":"div"},{"className":"alife-dt-card-common-table-sortable-value","index":0,"prefix":">","tag":"span","value":"span.alife-dt-card-common-table-sortable-value"}]}],"ExtractTable":0},{"objNextLinkElement":"","iMaxNumberOfPage":5,"iMaxNumberOfResult":-1,"iDelayBetweenMS":1000,"bContinueOnError":false})
TracePrint(arrayData)


第一行代码,是上次打开网页,现抓的,关闭浏览器之后再次打开,抓出来的就是空白。

第二行代码,是打开浏览器之后,重新抓取的,就可以抓到数据。

我对比了下,两行代码都相同,而且元素、目标和css也都是相同的,但不知道为什么每次重新打开,都需要重新抓取才能得到数据,想知道为什么?怎么才能不用总是重新抓,需要更改哪里?


下面是第一个需要抓的元素的CSS

{"html":{"tagName":"span","attrMap":{"css-selector":"body>div>div>div>div>div>div>div>div>div>div>div>div>div>div>div>div>div>div>div>div>div>table>tbody>tr>td>div>span"},"index":2},"wnd":[{"app":"chrome","cls":"Chrome_WidgetWin_1","title":"*"},{"cls":"Chrome_RenderWidgetHostHWND","title":"Chrome Legacy Window"}]}


"index":2 每个元素之间间隔是2,(即下一个元素是"index":4)


下面是元数据定义

{"Columns":[{"props":["text"],"selecors":[{"className":"oui-card-content","index":0,"prefix":"","tag":"div","value":"div.oui-card-content"},{"className":"contentContainer","index":0,"prefix":">","tag":"div","value":"div.contentContainer"},{"className":"oui-table-wrapper","index":0,"prefix":">","tag":"div","value":"div.oui-table-wrapper"},{"className":"ant-table-wrapper oui-table oui-table-5231-d20f-d5fb","index":0,"prefix":">","tag":"div","value":"div.ant-table-wrapper.oui-table.oui-table-5231-d20f-d5fb"},{"className":"ant-spin-nested-loading","index":0,"prefix":">","tag":"div","value":"div.ant-spin-nested-loading"},{"className":"ant-spin-container","index":0,"prefix":">","tag":"div","value":"div.ant-spin-container"},{"className":"ant-table ant-table-default ant-table-scroll-position-left","index":0,"prefix":">","tag":"div","value":"div.ant-table.ant-table-default.ant-table-scroll-position-left"},{"className":"ant-table-content","index":0,"prefix":">","tag":"div","value":"div.ant-table-content"},{"className":"ant-table-body","index":0,"prefix":">","tag":"div","value":"div.ant-table-body"},{"className":"","index":0,"prefix":">","tag":"table","value":"table"},{"className":"ant-table-tbody","index":0,"prefix":">","tag":"tbody","value":"tbody.ant-table-tbody"},{"className":"ant-table-row oui-table-row-tree-node-1 ant-table-row-level-0","index":0,"prefix":">","tag":"tr","value":"tr.ant-table-row.oui-table-row-tree-node-1.ant-table-row-level-0"},{"index":0,"prefix":">","tag":"td","value":"td"},{"index":0,"prefix":">","tag":"div","value":"div"},{"className":"alife-dt-card-common-table-sortable-value","index":0,"prefix":">","tag":"span","value":"span.alife-dt-card-common-table-sortable-value"}]}],"ExtractTable":0}


下面是目标

{"html":[{"id":"op-cc-macroscopic-monitor-item-rank-table","tag":"DIV"}],"wnd":[{"app":"chrome","cls":"Chrome_WidgetWin_1","title":"*"},{"cls":"Chrome_RenderWidgetHostHWND","title":"Chrome Legacy Window"}]}

最新回复 (2)
  • 康乙文 4天前
    2


    因为你两次抓的确实不一样

  • 康乙文 4天前
    3
    试一下把变动的地方用*代替吧
返回
发新帖