> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graphext.com/llms.txt
> Use this file to discover all available pages before exploring further.

# extract_url_components

> Extract components from an URL. 

Let's say we have `http://www.cwi.nl:80/%7Eguido/Python.html;a=2;b=3?c=4,2&d=e#anchor` as our URL.
Then these components will be the following:

* `scheme`: URL scheme specifier (http)
* `domain`: Network location part ([www.cwi.nl:80](http://www.cwi.nl:80))
* `path`: Hierarchical path (/%7Eguido/Python.html)
* `params`: Parameters for last path element (a=2;b=3)
* `query`: Query component (c=4,2\&d=e)
* `fragment`: Fragment identifier (anchor)

For more information about these components you can check urllib's description [here](https://docs.python.org/3/library/urllib.parse.html#url-parsing).

## Usage

The following example shows how the step can be used in a recipe.

<Accordion title="Examples" icon="code" defaultOpen="true">
  <Tabs>
    <Tab title="Example 1">
      Use `http` as default scheme.

      ```stan theme={null}
      extract_url_components(ds.urls, {
        "default_scheme": "http",
      }) -> (
        ds.scheme,
        ds.domain,
        ds.path,
        ds.params,
        ds.query,
        ds.fragment
      )
      ```
    </Tab>

    <Tab title="Signature">
      General syntax for using the step in a recipe. Shows the inputs and outputs the step is expected to receive and will produce respectively. For futher details see sections below.

      ```stan theme={null}
      extract_url_components(urls: url, {
          "param": value,
          ...
      }) -> (
      	scheme: category,
      	domain: category,
      	path: category,
      	params: category,
      	query: category,
      	fragment: category
      )
      ```
    </Tab>
  </Tabs>
</Accordion>

## Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally
columns (`ds.first_name`), datasets (`ds` or `ds[["first_name", "last_name"]]`) or models (referenced
by name e.g. `"churn-clf"`).

<Accordion title="Inputs" icon="right-to-bracket">
  <ParamField path="urls" type="column[url]" required>
    The list of URLs you wish to decomponse.
  </ParamField>
</Accordion>

<Accordion title="Outputs" icon="right-from-bracket">
  <ParamField path="scheme" type="column[category]" required>
    URL scheme specifier (http).
  </ParamField>

  <ParamField path="domain" type="column[category]" required>
    Network location part ([www.cwi.nl:80](http://www.cwi.nl:80)).
  </ParamField>

  <ParamField path="path" type="column[category]" required>
    Hierarchical path (/%7Eguido/Python.html).
  </ParamField>

  <ParamField path="params" type="column[category]" required>
    Parameters for last path element (a=2;b=3).
  </ParamField>

  <ParamField path="query" type="column[category]" required>
    Query component (c=4,2\&d=e).
  </ParamField>

  <ParamField path="fragment" type="column[category]" required>
    Fragment identifier, like after hashtag (anchor).
  </ParamField>
</Accordion>

## Configuration

The following parameters can be used to configure the behaviour of the step by including them in
a json object as the last "input" to the step, i.e. `step(..., {"param": "value", ...}) -> (output)`.

<Accordion title="Parameters" defaultOpen="true" icon="sliders">
  <ParamField path="default_scheme" type="[string, null]" default="http">
    URL Default Scheme.
    If you wish to add a scheme (http, https...) prefix to those urls that don't have one, do it here.
    If you wish none to be added, use null instead.
  </ParamField>
</Accordion>
