Google Sheets – Create Automatically Updating Spreadsheet with Steam Info

formulasgoogle sheetsimportxml

How would I create an automatically updating Google spreadsheet containing information about Recent Activity in Steam?

Table must look like here:
Table example

But the hours column must automatically updating current hours from here:
Recent Activity

Steam acc: http://steamcommunity.com/id/PerfectPlays

Best Answer

You can do this with IMPORTXML.

In A2:

=IMPORTXML("http://steamcommunity.com/id/PerfectPlays", "//span[@class='actual_persona_name']")

In B2: either

=IMPORTXML("http://steamcommunity.com/id/PerfectPlays", "//div[@class='recentgame_quicklinks']/h2")

which will return "108.9 hours past 2 weeks", or

=REGEXEXTRACT(IMPORTXML("http://steamcommunity.com/id/PerfectPlays", "//div[@class='recentgame_quicklinks']/h2"),"[^ ]* [^ ]*")

where REGEXEXTRACT cuts the string down to "108.9 hours".

If you are going to do this for several account, you may want to have a column for Account Id, e.g., PerfectPlays. For example, if this column is C, the first parameter of IMPORTXML would be

"http://steamcommunity.com/id/"&C2