【问题标题】:How to Import images with IMPORTXML如何使用 IMPORTXML 导入图像
【发布时间】:2023-04-05 16:26:01
【问题描述】:

从网站导入:https://weather.interia.com/long-term-forecast-chicago,cId,49700

我正在尝试在以下类中导入图像 URL 列表:

单元格中的 URL A1

我尝试过使用

=IMPORTXML($A$1, "//img/@src")

虽然这确实会导入一些图像,但它不会导入所需的图像。

【问题讨论】:

    标签: image web-scraping google-sheets google-sheets-formula array-formulas


    【解决方案1】:

    你能做的最好的就是:

    =ARRAYFORMULA(IMAGE("https://weather.interia.com/i/icons-bg-light-2/"&ROW(A1:A60)&".png",3))
    


    更新:

    =ARRAYFORMULA(IMAGE("https://weather.interia.com/i/icons-bg-light-2/"&
     IFNA(VLOOKUP(IMPORTXML(
     "https://weather.interia.com/long-term-forecast-chicago,cId,49700", 
     "//span[@class='weather-forecast-longterm-list-entry-forecast-phrase']"), { 
     "Showers"            , 12;
     "Partly sunny"       , 3;
     "Cold"               , 31;
     "Mostly cloudy"      , 6;
     "Dreary"             , 8;
     "Cloudy"             , 7;
     "Mostly cloudy"      , 8;
     "Mostly sunny"       , 2;
     "Intermittent clouds", 4;
     "Freezing rain"      , 26;
     "Flurries"           , 19;
     "Sunny"              , 1;
     "Hazy sunshine"      , 5;
     "Snow"               , 22}, 2, 0))&".png", 3))
    

    【讨论】:

    • 好的,有没有办法导入它,以便它每天按照天气报告的顺序更新?
    • @取决于你有多想要它。答案已更新。请注意,您将需要在该 vlookup 中缺少图像的情况下扩展数据库
    • 在这里找到他们的图标映射来源:developer.accuweather.com/weather-icons 我会用这个,再次感谢!
    • @PeterChabot 不错的发现
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-26
    • 2017-01-20
    • 2022-10-31
    • 1970-01-01
    • 2014-10-01
    • 1970-01-01
    相关资源
    最近更新 更多