Specify the table to import via IMPORTHTML/IMPORTXML according to its title name

与世无争的帅哥 提交于 2021-02-10 14:35:22

问题


The tables change position and I need to specify which one to import according to their title, for example, the table below has the title Over/Under 2.5 soccer predictions

Site:
https://www.soccerstats247.com/predictions/brazil/serie-a/

Unsuccessful attempts:

1 - I tried to use IMPORTXML by specifying the table id, but the import results in all the data in one column, it does not import as a table:

=IMPORTXML("https://www.soccerstats247.com/predictions/brazil/serie-a/",
           "//table[@id='soccerContentPlaceHolder_gvOverUnderPredictions']//td")

2 - I tried to use IMPORTHML combined with IMPORTXML to define the title, but the result returns completely blank:

=ARRAYFORMULA(IMPORTHTML(A2,"table", VLOOKUP(A1, {
 TRIM(IMPORTXML(A2,"//h3[@id='1x2']")), ROW(INDIRECT("A1:A"&COUNTA(
 TRIM(IMPORTXML(A2,"//h3[@id='1x2']")))))}, 2, 0)))

The expected result would be like this:


回答1:


use:

=IMPORTXML("https://www.soccerstats247.com/predictions/brazil/serie-a/",
           "//table[@id='soccerContentPlaceHolder_gvOverUnderPredictions']/tbody/tr")



来源:https://stackoverflow.com/questions/65451069/specify-the-table-to-import-via-importhtml-importxml-according-to-its-title-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!