Feat: update qz.com selectors and tests (#538)

* feat: update qz.com selectors and tests

* chore: remove out of date fixture
pull/551/head^2
James Shakespeare 2 years ago committed by GitHub
parent 56a19bf934
commit 70e99d56cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -2,7 +2,7 @@ export const QzComExtractor = {
domain: 'qz.com',
title: {
selectors: ['header.item-header.content-width-responsive'],
selectors: ['article header h1'],
},
author: {
@ -10,15 +10,19 @@ export const QzComExtractor = {
},
date_published: {
selectors: ['.timestamp'],
selectors: [['time[datetime]', 'datetime']],
},
lead_image_url: {
selectors: [['meta[name="og:image"]', 'value']],
selectors: [
['meta[name="og:image"]', 'value'],
['meta[property="og:image"]', 'content'],
['meta[name="twitter:image"]', 'content'],
],
},
content: {
selectors: [['figure.featured-image', '.item-body'], '.item-body'],
selectors: ['#article-content'],
// Is there anything in the content you selected that needs transformed
// before it's consumable content? E.g., unusual lazy loaded images
@ -27,6 +31,6 @@ export const QzComExtractor = {
// Is there anything that is in the result that shouldn't be?
// The clean selectors will remove anything that matches from
// the result
clean: ['.article-aside', '.progressive-image-thumbnail'],
clean: [],
},
};

@ -14,8 +14,8 @@ describe('QzComExtractor', () => {
let url;
beforeAll(() => {
url =
'http://qz.com/863015/uber-is-rolling-out-self-driving-cars-in-san-francisco-in-open-defiance-of-california-dmv/';
const html = fs.readFileSync('./fixtures/qz.com/1481758330660.html');
'https://qz.com/africa/1807355/nigerias-economy-has-best-quarterly-growth-since-recession/';
const html = fs.readFileSync('./fixtures/qz.com/1582826662145.html');
result = Mercury.parse(url, { html, fallback: false });
});
@ -36,7 +36,7 @@ describe('QzComExtractor', () => {
// the article.
assert.equal(
title,
'Uber is launching self-driving cars in San Francisco the same way it does everything—without permission'
'Nigerias economy is making a comeback—but its still not happening fast enough'
);
});
@ -47,7 +47,7 @@ describe('QzComExtractor', () => {
// Update these values with the expected values from
// the article.
assert.equal(author, 'Alison Griswold');
assert.equal(author, 'Yomi Kazeem');
});
// qz doesn't appear to pass the date from the server,
@ -59,7 +59,7 @@ describe('QzComExtractor', () => {
// Update these values with the expected values from
// the article.
assert.equal(date_published, null);
assert.equal(date_published, '2020-02-24T16:26:29.000Z');
});
it('returns the lead_image_url', async () => {
@ -71,7 +71,7 @@ describe('QzComExtractor', () => {
// the article.
assert.equal(
lead_image_url,
'https://qzprod.files.wordpress.com/2016/12/uber-self-driving-volvo-sf-e1481735810897.jpg?quality=80&strip=all&w=1600'
'https://cms.qz.com/wp-content/uploads/2017/04/nigerians-at-a-lagos-island-market.jpg?quality=75&strip=all&w=1400'
);
});
@ -95,7 +95,7 @@ describe('QzComExtractor', () => {
// the article.
assert.equal(
first13,
'One of the Volvo XC90s Uber is debuting in San Francisco. (Uber) No'
'Since suffering a recession and full year of negative growth in 2016, Nigeria,'
);
});
});

Loading…
Cancel
Save