Web.BrowserContents

Updated on

Web.BrowserContents is a Power Query M function that returns the HTML for a specified URL, as viewed by a web browser. It has options to specify additional properties.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Web.BrowserContents(
   url as text,
   optional options as nullable record,
) as text

Description

Returns the HTML for the specified url, as viewed by a web browser. An optional record parameter, options, may be provided to specify additional properties. The record can contain the following fields:

  • ApiKeyName: If the target site has a notion of an API key, this parameter can be used to specify the name (not the value) of the key parameter that must be used in the URL. The actual key value is provided in the credential.
  • WaitFor: Specifies a condition to wait for before downloading the HTML, in addition to waiting for the page to load (which is always done). Can be a record containing Timeout and/or Selector fields. If only a Timeout is specified, the function will wait the amount of time specified before downloading the HTML. If both a Selector and Timeout are specified, and the Timeout elapses before the Selector exists on the page, an error will be thrown. If a Selector is specified with no Timeout, a default Timeout of 30 seconds is applied.

Examples

Returns the HTML for https://microsoft.com.

Web.BrowserContents("https://microsoft.com")

Returns the HTML for https://microsoft.com after waiting for a CSS selector to exist.

Web.BrowserContents(
  "https://microsoft.com", 
  [ WaitFor = [ Selector = "div.ready" ] ]
)

Returns the HTML for https://microsoft.com after waiting ten seconds.


Web.BrowserContents(
  "https://microsoft.com", 
  [ WaitFor = [ Timeout = #duration(0,0,0,10) ] ]
)

Returns the HTML for https://microsoft.com after waiting up to ten seconds for a CSS selector to exist.

Web.BrowserContents(
  "https://microsoft.com", 
  [ WaitFor = [ Selector = "div.ready", Timeout = #duration(0,0,0,10) ] ]
)

Other functions related to Web.BrowserContents are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/web-browsercontents