From 8c9982247b33745c162445e71effc1329f822605 Mon Sep 17 00:00:00 2001 From: Nitin Khanna Date: Wed, 8 Sep 2021 10:03:23 -0700 Subject: [PATCH] feat: Ladbible.com extractor (#624) * Ladbible.com extractors and test * CircleCI says timezone needs to be Europe/London aka BST Co-authored-by: Postlight Bot Co-authored-by: Jad Termsani <32297675+JadTermsani@users.noreply.github.com> --- fixtures/www.ladbible.com/1626477326151.html | 100 +++++++++++++++++ src/extractors/custom/index.js | 1 + .../custom/www.ladbible.com/index.js | 31 ++++++ .../custom/www.ladbible.com/index.test.js | 102 ++++++++++++++++++ 4 files changed, 234 insertions(+) create mode 100644 fixtures/www.ladbible.com/1626477326151.html create mode 100644 src/extractors/custom/www.ladbible.com/index.js create mode 100644 src/extractors/custom/www.ladbible.com/index.test.js diff --git a/fixtures/www.ladbible.com/1626477326151.html b/fixtures/www.ladbible.com/1626477326151.html new file mode 100644 index 000000000..7502a957f --- /dev/null +++ b/fixtures/www.ladbible.com/1626477326151.html @@ -0,0 +1,100 @@ + + + + + Aussie Government Sparks Fury Over Graphic And Confronting Covid-19 Ad + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Advert

Aussie Government Sparks Fury Over 'Graphic' And Confronting Covid-19 Ad

Published 

Aussie Government Sparks Fury Over 'Graphic' And Confronting Covid-19 Ad

The Australian government has copped backlash for publishing a confronting and graphic advertisement about the symptoms of coronavirus. +

As Greater Sydney comes to grips with a second major lockdown since the pandemic began, authorities have been warning everyone to heed the stay-at-home orders. +

The number of cases has been rising dramatically each day and officials have revealed people as young as teenagers have been admitted to ICU to help them battle the virus. +

To further drive home the requirement to stay at home to stay safe, an ad has been published for Sydney residents and it's making viewers feel very uncomfortable. +

Advert

It shows a woman in hospital with a ventilator and her very audible gaps for air make for a difficult watch. +

Since the video was uploaded, people have asked for it to be taken down because it's too grim (even though it's meant to shock people into realising this could be their reality if they catch Covid-19). +

Adjunct Professor UNSW Strategic Health Policy Consultant Bill Bowtell said on Twitter: "This ad should be immediately taken off air. +

Advert

"Today in Sydney a young girl with Covid - about the same age as the actor in the ad - is on a ventilator fighting for her life. This insensitive ad can only distress her family and friends. It is misconceived in every way." +

ICU specialist Tom Solano added: "As an ICU specialist please know that we'd never deliberately let you suffer like that. We'd try to get increased support before it got that bad." +

People also criticised the government for trying to scare them into staying at home when they are the ones who have stuffed up the vaccine rollout. +

Advert

One user wrote: "Scaring young people that can't get vaccines is not helpful." +

Another added: "And the first thing my 21 year old living in Sydney will ask me if he sees that ad is 'Mum when can I get vaccinated'...and I still can't give him that answer." +

While there was a lot of outrage on social media about the ad, there were many people who thought it was good to remind people just how bad it can get if a pandemic is allowed to run rampant. +

Australia's Chief Medical Officer Professor Paul Kelly said the whole point of the video is to shock. +

Advert

"There will be a new advertisement running from the Australian government tonight. It is quite graphic. We are only doing this because of the situation in Sydney. And it will be running in Sydney," Prof Kelly said. "It's meant to be graphic, it's meant to push that message home." +

Authorities have warned the situation is likely to get worse before it gets better as it will take several days before the lockdown measures affect the spread of the virus.

Featured Image Credit: Australian Government

Topics: Australia

Stewart Perrie
Advert
Advert
Advert
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/extractors/custom/index.js b/src/extractors/custom/index.js index 2c8bfbe3b..8325876d9 100644 --- a/src/extractors/custom/index.js +++ b/src/extractors/custom/index.js @@ -132,4 +132,5 @@ export * from './www.phoronix.com'; export * from './pitchfork.com'; export * from './biorxiv.org'; export * from './epaper.zeit.de'; +export * from './www.ladbible.com'; export * from './timesofindia.indiatimes.com'; diff --git a/src/extractors/custom/www.ladbible.com/index.js b/src/extractors/custom/www.ladbible.com/index.js new file mode 100644 index 000000000..663cd8b2c --- /dev/null +++ b/src/extractors/custom/www.ladbible.com/index.js @@ -0,0 +1,31 @@ +export const WwwLadbibleComExtractor = { + domain: 'www.ladbible.com', + + title: { + selectors: ['h1'], + }, + + author: { + selectors: ['[class*=Byline]'], + }, + + date_published: { + selectors: ['time'], + timezone: 'Europe/London', + }, + + lead_image_url: { + selectors: [['meta[name="og:image"]', 'value']], + }, + + content: { + selectors: ['[class*=ArticleContainer]'], + clean: [ + 'time', + 'source', + 'a[href^="https://www.ladbible.com/"]', + 'picture', + '[class*=StyledCardBlock]', + ], + }, +}; diff --git a/src/extractors/custom/www.ladbible.com/index.test.js b/src/extractors/custom/www.ladbible.com/index.test.js new file mode 100644 index 000000000..cec93058f --- /dev/null +++ b/src/extractors/custom/www.ladbible.com/index.test.js @@ -0,0 +1,102 @@ +import assert from 'assert'; +import URL from 'url'; +import cheerio from 'cheerio'; + +import Mercury from 'mercury'; +import getExtractor from 'extractors/get-extractor'; +import { excerptContent } from 'utils/text'; + +const fs = require('fs'); + +describe('WwwLadbibleComExtractor', () => { + describe('initial test case', () => { + let result; + let url; + beforeAll(() => { + url = + 'https://www.ladbible.com/news/latest-aussie-government-sparks-fury-over-graphic-and-confronting-covid-19-ad-20210711'; + const html = fs.readFileSync( + './fixtures/www.ladbible.com/1626477326151.html' + ); + result = Mercury.parse(url, { html, fallback: false }); + }); + + it('is selected properly', () => { + // This test should be passing by default. + // It sanity checks that the correct parser + // is being selected for URLs from this domain + const extractor = getExtractor(url); + assert.equal(extractor.domain, URL.parse(url).hostname); + }); + + it('returns the title', async () => { + // To pass this test, fill out the title selector + // in ./src/extractors/custom/www.ladbible.com/index.js. + const { title } = await result; + + // Update these values with the expected values from + // the article. + assert.equal( + title, + `Aussie Government Sparks Fury Over 'Graphic' And Confronting Covid-19 Ad` + ); + }); + + it('returns the author', async () => { + // To pass this test, fill out the author selector + // in ./src/extractors/custom/www.ladbible.com/index.js. + const { author } = await result; + + // Update these values with the expected values from + // the article. + assert.equal(author, 'Stewart Perrie'); + }); + + it('returns the date_published', async () => { + // To pass this test, fill out the date_published selector + // in ./src/extractors/custom/www.ladbible.com/index.js. + const { date_published } = await result; + + // Update these values with the expected values from + // the article. + assert.equal(date_published, '2021-07-11T21:00:00.000Z'); + }); + + it('returns the lead_image_url', async () => { + // To pass this test, fill out the lead_image_url selector + // in ./src/extractors/custom/www.ladbible.com/index.js. + const { lead_image_url } = await result; + + // Update these values with the expected values from + // the article. + assert.equal( + lead_image_url, + `https://www.ladbible.com/cdn-cgi/image/width=1200,quality=70,format=jpeg,fit=cover,dpr=1/https%3A%2F%2Fs3-images.ladbible.com%2Fs3%2Fcontent%2F788d729460eb11aa5ceadb28b93c0f8a.png` + ); + }); + + it('returns the content', async () => { + // To pass this test, fill out the content selector + // in ./src/extractors/custom/www.ladbible.com/index.js. + // You may also want to make use of the clean and transform + // options. + const { content } = await result; + + const $ = cheerio.load(content || ''); + + const first13 = excerptContent( + $('*') + .first() + .text(), + 13 + ); + + // Update these values with the expected values from + // the article. + assert.equal( + first13, + 'The Australian government has copped backlash for publishing a confronting and graphic advertisement' + ); + }); + }); +});