There are two primary ways to handle differing layouts:
By comma-separating your selectors, Diffbot’s Custom API will look for all possible matches when extracting data. So if one layout provides data using a class name of
.favorites and another layout uses a class name of
.likes, and you wish to extract either using the same field, you can use the selector of
.likes,.favorites to support both templates/layouts. The “likes” and “favorites” data will be returned in your single field.
Diffbot Custom APIs will only return data for a field if its selectors are found on the page; empty fields will be suppressed. So you can also simply create a new field name for new fields on different templates.
For instance, in the above example, you could create one field named likes with a selector of
.likes, and one field named favorites with a selector named
.likes is found on a page, the likes field will be returned; when
.favorites is found, the favorites field will be returned.
Updated 16 days ago