The Query Cleaner addon can be used to clean up the request URL GET query parameters at the output of the spider in accordance with the patterns provided by the user.

In order to enable it, use at least one of the addon-specific settings: QUERYCLEANER_REMOVE or QUERYCLEANER_KEEP. The first one specifies a pattern (regular expression) that a query parameter name must match in order to be removed from the URL (all the others will be accepted). And the second one specifies a pattern that a query parameter name must match in order to be kept in the URL (all the others will be removed). You can combine both if some query parameters patterns should be kept and some should not. The remove pattern has precedence over the keep one.

Note that you can specify a list of parameter names by using the | (OR) regex operator. For example, the pattern search|login|postid will match query parameters search, login and postid. This is by far the most common usage case. And by setting QUERYCLEANER_REMOVE value to .* you can completely remove all URL queries.

Supported settings:


The addon is implicitly enabled when one of these settings is provided.

Let’s suppose that the spider extracts URLs like:

We want to leave only the parameter pid. To achieve this objective we can use either QUERYCLEANER_REMOVE or QUERYCLEANER_KEEP. In the first case, the pattern would be cid|ttda. In the second case, pid. The best solution depends on a particular case, that is, how the query filters will affect any other URL that the spider is expected to extract.