Skip to main content
Version: 2.3


Represents a pseudo-URL (PURL) - an URL pattern used by web crawlers to specify which URLs should the crawler visit. This class is used by the utils.enqueueLinks() function.

A PURL is simply a URL with special directives enclosed in [] brackets. Currently, the only supported directive is [RegExp], which defines a JavaScript-style regular expression to match against the URL.

The PseudoUrl class can be constructed either using a pseudo-URL string or a regular expression (an instance of the RegExp object). With a pseudo-URL string, the matching is always case-insensitive. If you need case-sensitive matching, use an appropriate RegExp object.

For example, a PURL[(\w|-)*] will match all of the following URLs:


Be careful to correctly escape special characters in the pseudo-URL string. If either [ or ] is part of the normal query string, it must be encoded as [\x5B] or [\x5D], respectively. For example, the following PURL:[\x5B]load[\x5D]=1

will match the URL:[load]=1

If the regular expression in the pseudo-URL contains a backslash character (), you need to escape it with another back backslash, as shown in the example below.

Example usage:

// Using a pseudo-URL string
const purl = new Apify.PseudoUrl('[(\\w|-)+]', {
userData: { foo: 'bar' },

// Using a regular expression
const purl2 = new Apify.PseudoUrl(/http:\/\/www\.example\.com\/pages\/(\w|-)+/);

if (purl.matches('')) console.log('Match!');

new PseudoUrl(purl, requestTemplate)


  • purl: string | RegExp - A pseudo-URL string or a regular expression object. Using a RegExp instance enables more granular control, such as making the matching case sensitive.
  • requestTemplate: RequestOptions - Options for the new Request instances created for matching URLs by the utils.enqueueLinks() function.


Determines whether a URL matches this pseudo-URL pattern.


  • url: string - URL to be matched.


boolean - Returns true if given URL matches pseudo-URL.


Creates a Request object from a provided requestTemplate and a given URL or an object that specifies \$Request properties. In case of a collision the properties will override the template, except for userData, which will be merged together, with the userData property having preference over the template. This enables dynamic overriding of the template.


  • urlOrProps: string | Object<string, *>