Skip to main content

Facilitate clustering of similar URLs of a website

Project description

This package facilitates the clustering of similar URLs of a website.

Live demo:

General information

You give a (preferably long and complete) list of URLs as input e.g.:

urls = [




You get a list of clusters as a result. For each cluster you get:

  • a REGEX that matches all cluster URLs
  • a HUMAN readable string representing the cluster
  • a list with all matched cluster URLs

So for our example the result is:





When to use

This is most useful for website analysis tools that report findings to the user. E.g. a service that crawls your website and reports page loading time may find that 10,000 pages take >2 seconds to load. Instead of listing 10,000 URLs it’s better to cluster them. So the end user will see something like:

Slow pages (>2 secs):
-                             (1 URL)
-                      (1 URL)
-[...]               (578 URLs)
-[...]&tag2=[...]   (409 URLs)
-[NUMBER]          (7209 URLs)

How it works:

URLs are grouped by domain. Only same domain URLs are clustered.

URLs are then grouped by a signature which is the number of path elements and the number of QueryString parameters & values the URL has.


URLs with the same signature are inserted in a tree structure. For each part (path element or QS parameter or QS value) two nodes are created:

  • One with the verbatim part.
  • One with the reduced part i.e. a regex that could replace the part.

Leaf nodes hold the number of URLs that match and the number of reductions.

E.g. inserting URL will create 2 top nodes:

root 1: `article`
root 2: `[^/]+`

And each top node will have two children:

child 1: `123`
child 2: `\d+`

Inserting 3 URLs of the form /article/[0-9]+ would lead to a tree like this:

       `article`                        `[^/]+`
  /    /      \     \             /    /      \     \
`123`  `456`  `789`  `\d+`      `123`  `456`  `789`  `\d+`
1 URL  1 URL  1 URL  3 URLs     1 URL  1 URL  1 URL  3 URLs
0 re   0 re   0 re   1 re       1 re   1 re   1 re   2  re

The final step is to choose the best leafs. In this case article -> \d+ is best because it macthes all 3 URLs with 1 reduction so the cluster returned is[NUMBER]


Copyright (c) 2015 Dimitris Giannitsaros.

Licensed under the MIT License.

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
urlclustering-0.4.1.tar.gz (6.5 kB) Copy SHA256 hash SHA256 Source None Oct 19, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page