You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mercury-parser/src/extractors/custom/www.si.com/index.js

53 lines
1.2 KiB
JavaScript

export const WwwSiComExtractor = {
domain: 'www.si.com',
title: {
selectors: ['h1', 'h1.headline'],
},
author: {
selectors: [['meta[name="author"]', 'value']],
},
date_published: {
selectors: [['meta[name="published"]', 'value']],
// timezone: 'America/New_York',
},
dek: {
selectors: ['.m-detail-header--dek'],
},
lead_image_url: {
selectors: [['meta[name="og:image"]', 'value']],
},
content: {
selectors: [
'.m-detail--body',
['p', '.marquee_large_2x', '.component.image'],
],
// Is there anything in the content you selected that needs transformed
// before it's consumable content? E.g., unusual lazy loaded images
transforms: {
noscript: $node => {
const $children = $node.children();
if ($children.length === 1 && $children.get(0).tagName === 'img') {
return 'figure';
}
return null;
},
},
// Is there anything that is in the result that shouldn't be?
// The clean selectors will remove anything that matches from
// the result
clean: [
['.inline-thumb', '.primary-message', '.description', '.instructions'],
],
},
};