gpt4 book ai didi

How do I import images from an HTML table into Google Sheets using IMPORTXML?(如何使用IMPORTXML将图像从HTML表格导入到Google Sheet中?)

转载 作者:bug小助手 更新时间:2023-10-25 11:19:26 26 4
gpt4 key购买 nike



I'm trying to import portions of this data table into a spreadsheet in order to reference it for other sheets. I've been able to get the text of the table using the =IMPORTHTML formula, but to my understanding the only way to import the images besides manually using =IMAGE() for each entry (which I'd like to avoid if possible since the table has around 400 entries) is to use =IMPORTXML, which I've been having difficulties with since I'm unfamiliar with the XML format.

我正在尝试将此数据表的一部分导入到电子表格中,以便在其他表格中引用它。我已经能够使用=IMPORTHTML公式获得表的文本,但据我所知,除了为每个条目手动使用=IMAGE()(如果可能的话,我希望避免这样做,因为表大约有400个条目),导入图像的唯一方法是使用=IMPORTXML,因为我不熟悉XML格式。


Here's the formula I'm using for the text portions of the table, since I only need data from a few columns: =QUERY(ImportHtml("https://nookipedia.com/wiki/Villager/New_Leaf", "table", 1), "SELECT Col2,Col3,Col5")

下面是我用于表格文本部分的公式,因为我只需要几列中的数据:=QUERY(ImportHtml(“https://nookipedia.com/wiki/Villager/New_Leaf”,“TABLE”,1),“SELECT COL2,COL3,COL5”)


I was able to find a very similar question that had this solution by majinnaibu:

我找到了一个非常相似的问题,它的解决方案是由majinnaibu提出的:


ArrayFormula(
Image(
ImportXML(
"https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Hisui_Pok%C3%A9dex_number",
"/html/body/div/div/div/div/div/div/table[2]/tbody/tr//td/following-sibling::th/a/img/@src"
),
4,
64,
64
)
)

I tested this in my sheet and it worked with the Pokémon images, but I've been struggling to find the XPath query I need for the images I'm trying to use. That's the part I need help with.

我在我的工作表中测试了这一点,它与神奇宝贝图像,但我一直在努力找到我想要使用的图像所需的查询。这就是我需要帮助的部分。


更多回答

I have to apologize for my poor English skill. Unfortunately, I cannot understand your question. Can I ask you about the details of your expected value? First, I would like to correctly understand your question.

我不得不为我糟糕的英语水平道歉。不幸的是,我听不懂你的问题。我能问一下你的期望值的详细情况吗?首先,我想正确理解你的问题。

Related question: Extracting images and Alt tags

相关问题:提取图像和Alt标签

Related resource (Google Docs Editors Help): Scraping Images and Alt Text from a website

相关资源(Google Docs编辑器帮助):从网站中抓取图像和Alt文本

优秀答案推荐

Try this:

试试这个:


=QUERY({QUERY({IMPORTXML("https://nookipedia.com/wiki/Villager/New_Leaf","//img[contains(@src,'Texture')]/@alt"),IMPORTXML("https://nookipedia.com/wiki/Villager/New_Leaf","//img[contains(@src,'Texture')]/@src")},"select Col1, Col2 label Col1 'Image name', Col2 'URL'"),QUERY({ImportHtml("https://nookipedia.com/wiki/Villager/New_Leaf", "table", 1)}, "SELECT Col2,Col3,Col5")},"select Col1, Col2, Col3, Col4, Col5")

=QUERY({QUERY({IMPORTXML(“https://nookipedia.com/wiki/Villager/New_Leaf”,“//img[包含(@src,‘纹理’)]/@alt”),IMPORTXML(“https://nookipedia.com/wiki/Villager/New_Leaf”,“//img[包含(@src,‘纹理’)]/@src”)},“选择COL1,COL2标签COL1‘图像名称’,COL2‘URL’”),QUERY({ImportHtml(“https://nookipedia.com/wiki/Villager/New_Leaf”,“表”,1)},“SELECT COL2,COL3,COL5”)},“选择COL1,COL2,COL3,COL4,COL5”)




The answer consists of two nested QUERY/IMPORTXML & QUERY/IMPORTHTML.

答案由两个嵌套的查询/IMPORTXML&Query/IMPORTHTML组成。



  • QUERY/IMPORTXML

    查询/IMPORTXML



    • XPath = Image name: "//img[contains(@src,'Texture')]/@alt")

    • XPath = Image URL: "//img[contains(@src,'Texture')]/@src"



  • QUERY/IMPORTHTML - this is the OP's own formula to extract the text

    QUERY/IMPORTHTML-这是OP自己的公式,用于提取文本






RESULTS - Extract

结果-摘录


sample


更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com