<!-- https://learnsql.cpetoday.com/functions/m/web-page -->
# Web.Page

Language: Power Query M
Category: Data sources
Syntax: Web.Page(html)
Summary: Reads an HTML web page and returns the tables it contains, so you can pick the one you need.
Returns: A table with a row for each table on the page. Its Data column holds each table's rows.
Level: Intermediate
Related: Web.Contents, Json.Document, Csv.Document, Table.PromoteHeaders, Table.SelectColumns

## What it does
Web.Page reads an HTML page and finds the tables in it. It is useful for a public table that has no download, such as a published rate schedule or a list of holidays. The page is read as it is, so the query works until the page layout changes.

## Syntax and arguments
- `html`: the page content. In practice, pass the result of Web.Contents: `Web.Page(Web.Contents("https://www.example.com/rates"))`.

## Example
A published table of standard mileage rates appears on a web page. The query reads the page and takes the first table on it.

```powerquery
let
    Source = Web.Page(Web.Contents("https://www.example.com/mileage-rates")),
    Tables = Source{0}[Data],
    WithHeaders = Table.PromoteHeaders(Tables, [PromoteAllScalars = true])
in
    WithHeaders
```

`Source` has one row per table on the page, so `{0}[Data]` takes the first table's rows. The headers are promoted from the first row. The address is a placeholder.

## Example: a second, different use
Choosing the table by its position in a list of tables after a quick check of the page. Look at the Source table in the editor to see which row holds the table you need.

## Things to watch
- Web pages change layout without notice. Check the row count and the headers after each refresh.
- The table you want may not be the first one on the page. Count rows in the Source table before you choose.
- Check the site's terms before you copy its data into a report. Prefer a published file or an API when one exists.
- Values are text when they come from a page. Convert the types after the headers are right.

## In business terms
Published rate tables, fee schedules and public reference data are sometimes only on a web page. Keep a dated copy of what you pulled, because a page can change after the figures were used.
