Dear Experts,
I’m posting this to seek help in retrieving data from multiple web pages that follow the same URL pattern. I used the following code (with Copilot’s suggestions) to load the pages from 1198 to 1242, but I couldn’t get it to work. Could someone please help me with the correct M code?
let
PageNumbers = {1198..1242},
BaseUrl = "https://www.cms.gov/icd10m/FY2024-version41.1-fullcode-cms/fullcode_cms/P",
Urls = List.Transform(PageNumbers, each BaseUrl & Text.From(_) & ".html"),
GetPageData = (url as text) =>
try
Web.Page(Web.Contents(url))
otherwise
null,
Pages = List.Transform(Urls, each GetPageData(_)),
CombinedTables = List.Transform(
Pages,
each if _ <> null and List.Count(_) > 3 then _{3}[Data] else null
),
FilteredTables = List.RemoveNulls(CombinedTables),
FinalTable = if List.Count(FilteredTables) > 0 then Table.Combine(FilteredTables) else #table({}, {})
in
FinalTable
I’m posting this to seek help in retrieving data from multiple web pages that follow the same URL pattern. I used the following code (with Copilot’s suggestions) to load the pages from 1198 to 1242, but I couldn’t get it to work. Could someone please help me with the correct M code?
let
PageNumbers = {1198..1242},
BaseUrl = "https://www.cms.gov/icd10m/FY2024-version41.1-fullcode-cms/fullcode_cms/P",
Urls = List.Transform(PageNumbers, each BaseUrl & Text.From(_) & ".html"),
GetPageData = (url as text) =>
try
Web.Page(Web.Contents(url))
otherwise
null,
Pages = List.Transform(Urls, each GetPageData(_)),
CombinedTables = List.Transform(
Pages,
each if _ <> null and List.Count(_) > 3 then _{3}[Data] else null
),
FilteredTables = List.RemoveNulls(CombinedTables),
FinalTable = if List.Count(FilteredTables) > 0 then Table.Combine(FilteredTables) else #table({}, {})
in
FinalTable