我使用這個公式來獲取資料:
importXML("https://at.fuelo.net/fuel/type/gasoline?lang=en"; "//table[@class=('table')]//tr")
如何在沒有標志的情況下獲得價格€/l?
uj5u.com熱心網友回復:
使用substitute()or regexreplace(),iferror()像這樣:
=arrayformula(
iferror(
iferror(
0.001 *
value(
substitute(
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en", "//table[@class=('table')]//tr"),
" €/l", ""
)
),
0.001 *
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en", "//table[@class=('table')]//tr")
),
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en", "//table[@class=('table')]//tr")
)
)
或者,根據您的語言環境,它可能是:
=arrayformula(
iferror(
iferror(
0,001 *
value(
substitute(
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en"; "//table[@class=('table')]//tr");
" €/l"; ""
)
);
0,001 *
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en"; "//table[@class=('table')]//tr")
);
importxml("https://at.fuelo.net/fuel/type/gasoline?lang=en"; "//table[@class=('table')]//tr")
)
)
僅當您的電子表格區域設定使用句點作為小數點時,才需要0.001 *位和外部。iferror()
uj5u.com熱心網友回復:
采用:
=QUERY({IMPORTXML("https://at.fuelo.net/fuel/type/gasoline?lang=en";
"//table[@class=('table')]//tr")\ INDEX(SUBSTITUTE(IMPORTXML(
"https://at.fuelo.net/fuel/type/gasoline?lang=en";
"//table[@class=('table')]//tr"); " €/l"; "");;2)};
"select Col1,Col4,Col3")

更新:
=ARRAYFORMULA(IFNA(TEXT(REGEXEXTRACT(SUBSTITUTE(
IMPORTXML("https://at.fuelo.net/fuel/type/gasoline?lang=en";
"//table[@class=('table')]//tr"); "."; ",");
"\d ,\d ")*GOOGLEFINANCE("currency:EURUSD"); "0.00"); TRIM(
IMPORTXML("https://at.fuelo.net/fuel/type/gasoline?lang=en";
"//table[@class=('table')]//tr"))))

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/477120.html
