Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I extract the domain out of an URL?

Tags:

perl

How do I extract the domain out of an URL? Is there a Perl Module? I could not find any.

like image 243
Timmy Avatar asked May 05 '09 21:05

Timmy


People also ask

How do you find the domain name of a website?

Use ICANN Lookup The Internet Corporation for Assigned Names and Numbers (ICANN) is a non-profit organization that collects domain information. Use the ICANN Lookup tool to find your domain host. Go to lookup.icann.org. In the search field, enter your domain name and click Lookup.

How do I extract part of a URL in Excel?

Extract the Hyperlink URL with a Click You can then copy and paste the URL from the browser address bar back into Excel. Highlight the URL and press Ctrl + C to copy, then go back to Excel and press Ctrl + V to paste the URL into a new cell.

How do I find the domain of a string?

Firstly, we'd need to extract the host from the given URL value. We can use the URI class: String urlString = "https://www.baeldung.com/java-tutorial"; URI uri = new URI(urlString); String host = uri. getHost();


1 Answers

The URI module can parse URIs for you in a nice OO-ish way. To get the domain part:

my $url = URI->new( "http://www.stackoverflow.com/" );
my $domain = $url->host;
print $domain;
like image 83
friedo Avatar answered Oct 19 '22 14:10

friedo