Pages

Easiest way to Load HTML table in Google spreadsheet

We most of the time try to fetch data from some websites and store in google spread sheet , To do this we spend lots of time to scraping webpages & digging required data in them.

But one of the easiest way to load  HTML table from any webpage to use Google spreadsheet Import feature ( Google is very good at such things !)

To scrap such data I have spent lots of trying writing some scrips in multiple programming languages.But today I am going to tell you easiest way to do it.

Google Docs being able to import tables from websites. And indeed, it has a very useful function called ImportHtml that will scrape a table from a page. Also there are many other options are provided for importing data from live URLs. When you start writing Import... In first cell of your spreadsheet it will show you all options for importing various data as shown below


Importing HTML in Google spreadsheet snap


To extract a table, create a new spreadsheet and enter the following expression in the top left
=ImportHtml(URL, "table", num)
URL here is the URL of the page (between quotation marks), “table” is the element to look for (Google Docs can also import lists), and num is the number of the element (e.g. if there are two tables on same page you can load 2nd table using s as num value), in case there are more on the same page (which is rather common for tables). In our example I am loading table from page "http://www.w3schools.com/html/html_tables.asp".

So I write something like =ImportHtml("http://www.w3schools.com/html/html_tables.asp", "table", 1)  and hit enter to import data.




Once this is done, Google Docs retrieves the data and inserts it into the spreadsheet, including the headers. The last step is to download the spreadsheet as a CSV file.



This is very simple and quick, and a much better idea than writing a custom script. Of course, the real solution would be to offer all data as a CSV file in addition to the table to begin with. But until that happens, we will need tools like this to get the data into a format that is actually useful.

You can follow THIS to know more.