SEO4Ajax - Crawler documentation

Crawler documentation

The purpose of this document is to give you a deeper insight on how the SEO4Ajax service works. It details the behavior of the system and notably will help you to have a better understanding of how the API and advanced options work.

Overview

The crawler is the main component of the service and can be compared to a conductor; it takes care of capturing all pages from a site and keeps these captures updated. The page capturing process is delegated to Chrome. To ensure the crawler can handle captures in parallel, multiple headless browsers run in a pool which can be scaled or reduced on demand. The pages captured by headless browsers are saved in a cache, which is used to send captures to bots as soon as possible. Capture contents are also parsed by the crawler in order to find inner links. This analysis helps it to discover and capture all the pages of the site.

How does the crawling process work?

Each time a path is being processed, the crawler updates in the database the state of the path ensuring the crawling process goes smoothly. Here are the possible states of a path:

How is a capture analysed?

First of all, the crawler searches for the <meta name="robots" content="nofollow"> tag. If it is found, then none of the page inner links will be captured. Otherwise, it looks for the following tags and considers the values of their href attribute as inner links:

Caution

Note that the SEO4Ajax crawler does not click on any HTML element. So it is not able to find URLs in buttons or links only activated by JavaScript and without a href attribute.

Additional rules are applied in order to determine if inner links must be captured or not. Link paths are ignored if a path:

When considered as valid, the state of the path will be set to "pending" in the database.

How does the crawler select paths to capture?

When the crawler selects the next path to capture, it searches in the database for a path that:

The priority of a path is determined by the following rules:

The priority of a path can also be explicitly set through the authenticated API.

What are rewrite rules?

Rewrite rules allow for rewriting a path just before its state is set to "pending" in the database (i.e., before capturing new or expired paths) or before replying to bots. They have multiple purposes such as removing query parameters, applying HTTP redirections, or returning 404's for invalid pages. The syntax of rewrite rules is based on regular expressions and options similar to the format of configuration files in Apache. More information about rewrite rules syntax can be found here.

How does the crawler know when a page is ready to be captured?

In order to capture successfully a page, the crawler needs to know when the rendering of the page content has finished. Thus it monitors network requests and responses to detect when the page is ready to be captured. When there is no more network activity (i.e., all responses have been received), it gives JavaScript 3 seconds (by default) to render the page. This period can be changed via the "JavaScript timeout" option in the site settings. If a request is sent during this period, the timer is cancelled, and this procedure is repeated until the 3 seconds elapsing. When the timer finally expires, the page is captured. This capture process can be better controlled by calling the window.onCaptureReady callback in the web application. This technique is the most efficient if the application knows exactly when the page is rendered. More information on how to use these features can be found here.

How to configure the crawler behavior?

The crawler permanently looks for site updates. In fact, every time the public API receives a GET request from bots, while sending back the capture, it also verifies it is not expired. If expired, it automatically sets its state to "pending" in order to recapture it. Then if the capture contains new or expired inner links, they are also captured and so on. For more control over this default behavior, 3 options can be independently disabled in the site settings in order to prevent the crawler to:

More information about these options can be found here.

How to add or remove paths in the database?

There are multiple options to add new paths:

To remove paths you can either: