https://github.com/rvflash/publicsuffix-sql
Mysql's functions to parse domain names based on the Public Suffix List.
https://github.com/rvflash/publicsuffix-sql
mysql mysql-functions public-suffix-list
Last synced: 2 months ago
JSON representation
Mysql's functions to parse domain names based on the Public Suffix List.
- Host: GitHub
- URL: https://github.com/rvflash/publicsuffix-sql
- Owner: rvflash
- License: mit
- Created: 2018-01-05T14:26:17.000Z (over 8 years ago)
- Default Branch: stable
- Last Pushed: 2018-01-05T14:34:49.000Z (over 8 years ago)
- Last Synced: 2025-03-23T09:35:14.764Z (about 1 year ago)
- Topics: mysql, mysql-functions, public-suffix-list
- Size: 37.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Public Suffix for MySql
Mysql's functions to parse domain names based on the Public Suffix List.
## Installation
```bash
$ git clone https://github.com/rvflash/publicsuffix-sql
```
## Testing
Go into the source directory and starts the Docker.
```bash
$ cd publicsuffix-sql
$ docker-compose up
$ docker exec -ti $(docker ps -lq) bash
```
In the new prompt, opens the MySql client:
```bash
$ mysql -h db -u root -ps3cr3tp4ssw0rd ps
```
## Features
* The function named `hostname` extracts the hostname in a URL.
* Function named `domain` returns the hostname without the sub-domain (ex: google.com.au).
* The `sld` and `tld` functions returns respectively the second level domain (ex: com.au) and top level domain (ex: au).
```
> select hostname("https://www.google.com.au/search?q=golang");
+-------------------------------------------------------+
| hostname("https://www.google.com.au/search?q=golang") |
+-------------------------------------------------------+
| www.google.com.au |
+-------------------------------------------------------+
1 row in set (0.00 sec)
> select domain("https://www.google.com.au/");
+--------------------------------------+
| domain("https://www.google.com.au/") |
+--------------------------------------+
| google.com.au |
+--------------------------------------+
1 row in set (0.00 sec)
> select sld(domain("https://www.google.com.au/"));
+-------------------------------------------+
| sld(domain("https://www.google.com.au/")) |
+-------------------------------------------+
| com.au |
+-------------------------------------------+
1 row in set (0.00 sec)
```