UrlProperty

=UrlProperty(
    string url, 
    string property, 
    string queryParam (optional),
    string queryValue (optional)
) : string

Results from function inside Excel


Purpose

Returns property of an URL.


Examples

In the following examples this url is used as reference A1:
https://niels@sub.domain.co.uk:1090/path/to/file.aspx?a=b&c=d=e#fragment

Absolute

Returns the absolute url. If the url is misspelled, i.e. htp:/mydomain.com this is corrected.

=UrlProperty("domain.com","absolute") =>
"http://domain.com"

=UrlProperty("https://mydomain.com","absolute") => 
"https://domain.com" 

=UrlProperty(A1,"absolute") => 
"https://niels@sub.domain.co.uk:1090/path/to/
file.aspx?a=b&c=d=e#fragment"

Host

Returns the host of the url.

=UrlProperty(A1,"host") => "sub.domain.co.uk"

Domain

Returns the domain of the url. UrlProperty is aware that some top level domain have second level domains (such as co.uk).

=UrlProperty(A1,"domain") => "domain.co.uk
=UrlProperty("sub.domain.com","domain") => "domain.com"

Origin

Returns the origin of the url (schema + port)

=UrlProperty(A1,"origin") => "https://sub.domain.co.uk"

Tld

Returns the top level domain of the url.

=UrlProperty(A1,"tld") => "uk"

Registrar

Returns the second level domain if applicable together with top level domain.

=UrlProperty(A1,"registrar") => "co.uk"
=UrlProperty("mydomain.com","registrar") => "com"

Fragment

Returns the fragment (location within a resource) of the url.

=UrlProperty(A1,"fragment") => "fragment"

User

Returns the user information of the url.

=UrlProperty(A1,"user") => "niels"

Scheme

Returns the scheme of the url.

=UrlProperty(A1,"scheme") => "http"

Port

Returns the port of the url.

=UrlProperty(A1,"port") => "1090"

Path

Returns the path referenced in the url if applicable.

=UrlProperty(A1,"path") => "/path/to/"

File

Returns the file name referenced in the url if applicable.

=UrlProperty(A1,"file") => "file.aspx"

Extension

Return the extension of the file referenced in the url if applicable.

=UrlProperty(A1,"extension") => "aspx"

Left

Returns the left part for the url.

UrlProperty("https://seotoolsforexcel.com/connectors?query=value";"left")
=>https://seotoolsforexcel.com/connectors

Name

Returns the name part of the domain.
=UrlProperty("https://seotoolsforexcel.com","name") =>"seotoolsforexcel"


QueryParam

If no queryParam is specified the entire querystring is returned. Otherwise returns the value of specified query parameter.

=UrlProperty(A1,"query","a") => "b"
=UrlProperty(A1,"query","c") => "d"
=UrlProperty(A1,"query","x") => ""

Adding a fourth parameter queryValue with property ´query´ allows you to set the queryValue of a queryParam in an url.

=UrlProperty("http://domain.com/Default.aspx?a=b&foo=x"
,"query","foo","bar")
=> "https://domain.com/Default.aspx?a=b&foo=bar"

Depth

Returns the "depth" of the path in the url.

=UrlProperty("https://seotoolsforexcel.com/","depth") => 0 
=UrlProperty("https://seotoolsforexcel.com/","depth") => 0 
=UrlProperty("https://seotoolsforexcel.com/foo","depth") => 1
=UrlProperty("https://seotoolsforexcel.com/foo/","depth") => 1
=UrlProperty("https://seotoolsforexcel.com/foo/bar","depth") => 2     
=UrlProperty("https://seotoolsforexcel.com/foo/bar/","depth") => 2  

See

Cookbook


Get help with this function in the community →