Skip to content

Instantly share code, notes, and snippets.

@matt40k
Created October 10, 2021 11:08
Show Gist options
  • Save matt40k/f952bf5209560da3cbba1d7c2321ff32 to your computer and use it in GitHub Desktop.
Save matt40k/f952bf5209560da3cbba1d7c2321ff32 to your computer and use it in GitHub Desktop.
PowerQuery M code for scrapping the Raspberry PI image stats
let
Source = Web.BrowserContents("https://rpi-imager-stats.raspberrypi.org"),
#"Extracted Table From Html" = Html.Table(Source, {{"Column1", "DIV.row:nth-child(3) > DIV.col-sm:nth-child(1) > TABLE.table.mt-4 > * > TR > :nth-child(1)"}, {"Column2", "DIV.row:nth-child(3) > DIV.col-sm:nth-child(1) > TABLE.table.mt-4 > * > TR > :nth-child(2)"}}, [RowSelector="DIV.row:nth-child(3) > DIV.col-sm:nth-child(1) > TABLE.table.mt-4 > * > TR"]),
#"Promoted Headers" = Table.PromoteHeaders(#"Extracted Table From Html", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Image", type text}, {"Percentage", Percentage.Type}}),
#"Add Timestamp" = Table.AddColumn(#"Changed Type", "Timestamp", each DateTime.LocalNow(), type datetime)
in
#"Add Timestamp"
let
Source = Web.BrowserContents("https://rpi-imager-stats.raspberrypi.org"),
#"Extracted Table From Html" = Html.Table(Source, {{"Column1", "DIV.row:nth-child(2) > DIV.col-sm:nth-child(1) > TABLE.table.mt-4 > * > TR > :nth-child(1)"}, {"Column2", "DIV.row:nth-child(2) > DIV.col-sm:nth-child(1) > TABLE.table.mt-4 > * > TR > :nth-child(2)"}}, [RowSelector="DIV.row:nth-child(2) > DIV.col-sm:nth-child(1) > TABLE.table.mt-4 > * > TR"]),
#"Promoted Headers" = Table.PromoteHeaders(#"Extracted Table From Html", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Operating System", type text}, {"Percentage", Percentage.Type}}),
#"Add Timestamp" = Table.AddColumn(#"Changed Type", "Timestamp", each DateTime.LocalNow(), type datetime)
in
#"Add Timestamp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment