Using Html.Table() To Extract URLs From A Web Page In Power BI/Power Query M

Last year I blogged about how to use the Text.BetweenDelimiters() function to extract all the links from the href attributes in the source of a web page. The code was reasonably simple but there’s now an even easier way to solve the same problem using the new Html.Table() function. This function doesn’t seem to be documented online yet, but the built-in documentation for the function available in the Query Editor is up-to-date:


Miguel Escobar also has a great post showing how to use it and the new Web.BrowserContents function here.

Here’s an example M query that extracts all the links that start with the letters “http” from my company homepage:

    Source = 
    Links = 
	   each [Attributes][href]}})


To explain what’s going on here:

  • Web.BrowserContents returns the text of the html DOM for the web page
  • In the second step Html.Table takes that text and searches for all <a> elements whose href attribute starts with the letters “http”. I found this CSS selector here.

23 responses

  1. Chris,

    This apparently doesn’t work the current version of Excel 365. Data, Get & Transform Data doesn’t recognize either of these functions:


  2. Pingback: Dew Drop - August 31, 2018 (#2794) - Morning Dew

  3. Pingback: Web Scraping with Html.Table in Power Query – BI Polar

  4. Hi Chris. Great Tutorial!
    I have a issue with the refresh when I use Power BI online with the Web.BrowserContents. I see this error message:
    Query contains unknown funtion name: Web.BrowserContents.
    Query contains unknown funtion name: Html.Table.
    Do you have any idea to fix it?

      • I’m using the lastest version of Power BI desktop. With the desktop i can refresh te webcontent, however when I publish to Power BI online I can’t refresh. The error message show that the query contains a unknown funcion related to HTML and Web Content. I’ll keep trying. Thanks!

  5. Pingback: Power BI/Power Query – Web Scraping (a full page with images) – Excel and BI

  6. Pingback: How to get the most out of Web.BrowserContents() - Foster BI

  7. Very interesting tutorial Chris, I tried to apply this but I’m still struggling to get data from Yahoo Finance – Income Statement Table. I need the Income Statement (Quarterly data) for Apple from this link:;.tsrc=fin-srch

    Since the page address does not change, I have not managed to extract Quarterly data instead of Annual data which appears in the initial page.

    Do you you have a suggestion on how to manipulate the table selector (Annual /Quarterly)?


  8. Pingback: Removing HTML Tags From Text In Power Query/Power BI « Chris Webb's BI Blog

  9. Hi Chris, if I’m trying to get a connection to a report that is intranet based (i.e. internal organizational http website) I’m having issues to connect. Do you have any suggestion on how to get that type of connection?

  10. Pingback: #powerbi Report to browse and watch sessions from #mbas 2019 using the #powerapp visual – Erik Svensen – Blog about Power BI, Power Apps, Power Query

  11. Hi Chris
    Is there any function in Power Query that can do the task .


    i have used this
    (URL) as table =>
    Source = Web.Page(Web.Contents(URL)),
    Data0 = Source{0}[Data],
    #”Changed Type” = Table.TransformColumnTypes(Data0,{{“Column1”, Int64.Type}, {“Column2”, type text}, {“Column3″, type text}}),
    #”Filtered Rows” = Table.SelectRows(#”Changed Type”, each ([Column1] null)),
    #”Removed Columns” = Table.RemoveColumns(#”Filtered Rows”,{“Column2″})
    #”Removed Columns”

    Source = Excel.CurrentWorkbook(){[Name=”LINKS”]}[Content],
    #”Changed Type” = Table.TransformColumnTypes(Source,{{“URL”, type text}}),
    #”Added Custom” = Table.AddColumn(#”Changed Type”, “Fetchdata”, each Companies([URL])),
    #”Expanded Fetchdata” = Table.ExpandTableColumn(#”Added Custom”, “Fetchdata”, {“Column1”, “Column3”}, {“Column1”, “Column3″})
    #”Expanded Fetchdata”


    to import data from the web page but it imports companies names only not link address
    want to insert a new column and get the link address to get the profile of each company .

    Thank You

  12. Pingback: Chris Webb's BI Blog: Removing HTML Tags From Text In Power Query/Power BI Chris Webb's BI Blog

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: