IMPORTHTML to scrape Wiki table specific column with Google Sheets

Viewed 52

I'm trying to scrape one specific column from Wiki table (if it exists), using IMPORTHTML+QUERY in sheets, but it doesn't always seem to work. In some cases when the column is missing it still returns data from other ones (instead of empty output), in other cases, it extracts multiple columns. Does anyone know a better way of doing this? Thanks. See examples

1 Answers

Although I'm not sure whether I could correctly understand your question, for example, how about the following sample formula? In this modification, I used IMPORTXML instead of IMPORTHTML.

Sample formula:

=IFERROR(JOIN(" ",IMPORTXML(A2,"//tr[./th[text()='Died']]/td")))

Testing:

When this sample formula is used for your provided sample Spreadsheet, the following result is obtained.

enter image description here

Note:

  • In this sample formula, I tested with only your showing URLs. So, I'm not sure whether this sample formula can be used for your all expected URLs.

Reference:

Related