Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web scraping 如何从导入的表中选择特定列?_Web Scraping_Google Sheets_Google Sheets Formula_Google Sheets Query_Google Query Language - Fatal编程技术网

Web scraping 如何从导入的表中选择特定列?

Web scraping 如何从导入的表中选择特定列?,web-scraping,google-sheets,google-sheets-formula,google-sheets-query,google-query-language,Web Scraping,Google Sheets,Google Sheets Formula,Google Sheets Query,Google Query Language,我在谷歌表单中使用以下公式来提取一些财务数据: =TRANSPOSE(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT,"table",4)) IMPORTHTML结果为 Forward Annual Dividend Rate 4 2.04 Forward Annual Dividend Yield 4 1.11% Trailing Annual Dividend Rate 3 1.94

我在谷歌表单中使用以下公式来提取一些财务数据:

=TRANSPOSE(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT,"table",4))
IMPORTHTML
结果为

Forward Annual Dividend Rate 4    2.04
Forward Annual Dividend Yield 4   1.11%
Trailing Annual Dividend Rate 3   1.94
Trailing Annual Dividend Yield 3  1.05%
5 Year Average Dividend Yield 4   2.02
Payout Ratio 4                    32.93%
Dividend Date 3                   Mar 11, 2020
Ex-Dividend Date 4                Feb 18, 2020
Last Split Factor 2               2:1
Last Split Date 3                 Feb 17, 2003
我正在对结果进行
转换,以准备查询数据:

Forward Annual Dividend Rate 4  Forward Annual Dividend Yield 4 Trailing Annual Dividend Rate 3 ...
2.04                            1.11%                           1.94                            ...
我需要的是
除息日期4
列的值(因此:
2020年2月18日
)(稍后还有其他列,因此我正在寻找通用解决方案)。我尝试了多种方法(见下文,但都会导致
#VALUE!
错误:

=QUERY(TRANSPOSE(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT","table",4)), "SELECT * LIMIT 2 OFFSET 1 WHERE COL=""Ex-Dividend Date 4"")")

=QUERY(TRANSPOSE(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT","table",4)), "SELECT [Ex-Dividend Date 4] LIMIT 2 OFFSET 1")
如何正确查询此表?

请尝试:

=INDEX(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT", 
 "table", 4), 8, 2)
或已格式化:

=TEXT(INDEX(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT", 
 "table", 4), 8, 2), "mm/dd/yyyy")
查询中

=QUERY(IMPORTHTML("https://finance.yahoo.com/quote/MSFT/key-statistics?p=MSFT", 
 "table", 4), "select Col2 where Col1 contains 'Ex-Dividend Date 4'", 0)