将查询正确格式化为Google表格/天气公式

时间:2020-01-14 23:19:49

标签: web-scraping google-sheets array-formulas google-sheets-query google-sheets-importxml

我有一个将与我联系的人的Google表格,其中包括“城市”和“州”。使用该位置,我想确定某个日期的天气和温度,然后将其输入到其自己的单元格中的相应行中。

这是我当前使用的公式:

=Query(IMPORTHTML("https://www.timeanddate.com/weather/usa/"&Substitute(lower(TRIM(A2))," ","-")&"/ext","table",1)," select Col3,Col4,Col5,Col6,Col8 where Col1='"&text(B2,"DDD")&Char(10)&text(B2,"MMM")&" "&index(split(B2,"/"),1,2)&"' ",2)

这将导致以下结果:

enter image description here

我想这样做: 第一行示例。

enter image description here

1 个答案:

答案 0 :(得分:2)

尝试:

=ARRAYFORMULA(QUERY(TO_TEXT(IMPORTHTML("https://www.timeanddate.com/weather/usa/"&
 SUBSTITUTE(LOWER(TRIM(A2)), " ", "-")&"/ext", "table", 1)), 
 "select Col3,Col4 
  where Col1 = '"&TEXT(B2, "DDD")&CHAR(10)&TEXT(B2, "MMM")&" "&DAY(B2)&"'", 0))

0