首页 > 解决方案 > 仅将 IMAGE 函数添加到通过 IMPORTXML 收集的一列数据中

问题描述

我从单个导入数据IMPORTXML并将其分为两列,如下所示:

=ArrayFormula(IFERROR(HLOOKUP(1,{1;IMPORTXML(A1,"

//table[@class='table squad sortable']//td[@class='photo']/a/img/@src | 
//table[@class='table squad sortable']//td[@class='name large-link']/a/@href")},

(ROW(A:A)+1)*2-TRANSPOSE(sort(ROW($A$1:$A$2)+0,1,0)))))

在此处输入图像描述

我想知道是否有任何方法不必多次调用 importxml 并IMAGE仅在第一列中添加该函数,因此我不必像目前那样将其单独放置。

电子表格链接: https ://docs.google.com/spreadsheets/d/10_G3QjcLcE9dYz_0m8PjPxHDAAaKL7BGEehTfmprYTQ/edit?usp=sharing

标签: web-scrapinggoogle-sheetsgoogle-sheets-formulaarray-formulasgoogle-sheets-importxml

解决方案


你可以用一个公式做的最好的事情是:

=ARRAYFORMULA({IFERROR(IMAGE(IMPORTXML(A1,
 "//table[@class='table squad sortable']//td[@class='photo']/a/img/@src"))), 
 QUERY(IFERROR(HLOOKUP(1, {1; IMPORTXML(A1,
 "//table[@class='table squad sortable']//td[@class='photo']/a/img/@src | //table[@class='table squad sortable']//td[@class='name large-link']/a/@href")},
 (ROW(A:A)+1)*2-TRANSPOSE(SORT(ROW($A$1:$A$2)+0, 1, 0)))), "where Col1 !=''", 0)})

0


推荐阅读