Forum Discussion
Extract data after html tag
- 1 year ago
pls try this
let Source = Text.FromBinary(Web.Contents("https://www.akamaistatus.com/")), Text = Text.BetweenDelimiters( Source, "<span class=""status font-large"">", "<span class=""last-updated-stamp font-small""></span>" ), ImportedText = List.RemoveMatchingItems( List.Transform(Lines.FromText(Text),(x)=> Text.Trim(x)),{""}){0} in ImportedText
Thank you Ahmedx ! That works perfectly...
Can you explain the following line and tell me where can I learn more about it?
ImportedText = List.RemoveMatchingItems( List.Transform(Lines.FromText(Text),(x)=> Text.Trim(x)),{""}){0}
-
Lines.FromText(Text): This function converts the variableTextinto a list of lines. Each line from the text becomes an individual element in the list. -
List.Transform(..., (x) => Text.Trim(x)): This applies a transformation to each line in the list created in step 1. The transformation involves trimming the whitespace from both the beginning and end of each line usingText.Trim(x). -
List.RemoveMatchingItems(..., {""}): This removes any empty strings (i.e.,"") from the list that resulted from the transformation in step 2. If any lines were just whitespace, they are removed at this point because they become empty after trimming. -
{0}: This refers to the first element of the remaining list after empty strings are removed. It extracts the first non-empty line of the original text.