Welcome folks today in this blog post we will be extracting bulk domain names from website url list
using extract-domain
library in javascript. All the full source code of the application is shown below.
Get Started
In order to get started you need to install the below library using the npm
command as shown below
npm i extract-domain
- urls = string|array
- returns string|array
1 |
<span class="pl-en">extractDomain</span><span class="pl-kos">(</span><span class="pl-s1">urls</span><span class="pl-kos">)</span><span class="pl-kos">;</span> |
ES6
1 |
<span class="pl-k">import</span> <span class="pl-s1">extractDomain</span> <span class="pl-k">from</span> <span class="pl-s">"extract-domain"</span><span class="pl-kos">;</span> |
1 |
<span class="pl-k">const</span> <span class="pl-s1">extractDomain</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"extract-domain"</span><span class="pl-kos">)</span><span class="pl-kos">;</span> |
Simple Example
1 2 3 4 5 6 7 8 9 10 11 12 |
const urls = [ "https://www.npmjs.com/package/extract-domain", "http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument", "http://user:password@example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument", "https://npmjs.com/package/extract-domain", "ftp://example.org/resource.txt", "this.is.my@email.com" ]; extractDomain(urls[0]); // npmjs.com extractDomain(urls); // [ 'npmjs.com', 'example.com', 'example.com', 'npmjs.com', 'example.org', 'email.com' ] |