From 99afa37b086979a5fd0286d1e8eb1a089397f9d2 Mon Sep 17 00:00:00 2001 From: Josiah Campbell <9521010+jocmp@users.noreply.github.com> Date: Tue, 21 Jan 2025 08:44:46 -0600 Subject: [PATCH] feat: Add custom parser - wccftech.com (#45) --- CHANGELOG.md | 3 +- fixtures/wccftech.com/1737405508147.html | 1076 +++++++++++++++++ src/extractors/custom/index.js | 1 + src/extractors/custom/wccftech.com/index.js | 30 + .../custom/wccftech.com/index.test.js | 77 ++ 5 files changed, 1186 insertions(+), 1 deletion(-) create mode 100644 fixtures/wccftech.com/1737405508147.html create mode 100644 src/extractors/custom/wccftech.com/index.js create mode 100644 src/extractors/custom/wccftech.com/index.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f0d236f..ff258f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Mercury Parser Changelog -### 2.3.1 +### 2.3.1 (Jan 21, 2025) +- [a11d811898] - feat: Add custom parser - wccftech.com (Josiah Campbell) [#45](https://github.com/jocmp/mercury-parser/pull/45) - [ba949c0c87] - feat: Add custom parser - channelnewsasia.com (Josiah Campbell) [#44](https://github.com/jocmp/mercury-parser/pull/44) - [6abdf5a862] - chore: Fix references to Postlight Parser in README (Josiah Campbell) diff --git a/fixtures/wccftech.com/1737405508147.html b/fixtures/wccftech.com/1737405508147.html new file mode 100644 index 0000000..1c26ba4 --- /dev/null +++ b/fixtures/wccftech.com/1737405508147.html @@ -0,0 +1,1076 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Nintendo Switch 2 Reveal Hit All the Right Notes, According to Analyst + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + +

Nintendo Switch 2 Reveal Hit All the Right Notes, According to Analyst

+ +
+ Alessio Palumbo + + + + + + + Comments + +
+ + +
+ + + + + Comments + +
+ +
+ +
+ + +
Nintendo Switch 2
+ + + + + +
+ +
+ + + + + +
+ + + + +

The Nintendo Switch 2 is finally official. After a couple of years of speculation, the Japanese company has unveiled its upcoming console, which will be released at some point in 2025.

+

The original Nintendo Switch launched nearly eight years ago. Its unique concept of a hybrid handheld/home console won over the gaming world, making it one of the best-selling consoles ever, with over 146 million units sold as of the last update. However, Nintendo is no stranger to missteps like the Wii U, the GameCube, or even the Nintendo 64 to an extent. Early reception for the Nintendo Switch 2 seems positive, but we reached out to MIDiA Research Games Analyst Rhys Elliott to get his perspective on the reveal.

+
Related Story Nintendo Switch 2 Officially Revealed With a New Trailer; Dedicated Direct Confirmed For April

+

Rhys, didn't Nintendo play it too safe?

+

It was smart of Nintendo to just make a bigger, better Switch. It is shrewd of them to leverage the inertia of the original. While the Nintendo Switch 2 plays it safe, the announcement video shows a range of quality-of-life improvements fans have wanted for years, such as a bigger screen (with a seemingly smaller bezel), a sturdier kickstand, and a bigger form factor for the Joy-Con. Nintendo might surprise us with something a little more out of left field, though — like that rumored mouse functionality.

+

What do you think of the naming specifically?

+

The straightforward name of ‘’Switch 2’’ is the right choice. Nintendo learned its hard lesson from the Wii U’s confusing naming convention and the abject failure of that console. Many consumers – not just casual but core ones too – thought the Wii U was an add-on for the Wii, similar to the Wii Fit Balance Board or the Wii Motion Plus. This marketing fumble almost destroyed all the gains Nintendo made with the Wii. Things would have been dire if the Switch hadn’t become a cultural phenomenon. And Nintendo’s leadership – more conservative than ever before – understands that.

+

Now that Nintendo has all its console eggs in the Switch basket, it simply cannot risk confusing fans. After all, Nintendo’s cross-entertainment efforts across film, theme parks, toys, and even alarm clocks all lead back to its core console brand. If the beating heart of the brand fails, everything falls apart.

+

Will core gamers flock to the Nintendo Switch 2 or not?

+

Core gamers are harder to please than more casual gamers and the general public. Other portable companion devices like the Steam Deck and the ROG Ally likely have more processing power than the Switch 2, and core gamers will draw these comparisons. We expect that many of these vocal-minority gamers will buy the Switch 2 nonetheless. And they are not even Nintendo’s main target audience here – families and more casual players are.

+

Nintendo has been awfully quiet about the fan-favorite Metroid Prime 4, which is a niche series relative to Nintendo’s other properties but would attract some core gamers. And Pokémon fandom would find a faster-running version of Pokémon Legends: Z-A enticing, as framerate and performance issues seen in the Switch’s more recent Pokémon games have been a major pain point for that community.

+

What do you think about the software outlook for the new console, both from first-party and third-party?

+

Nintendo confirmed that there will be Switch 2 exclusive games. Mario Kart 8 Deluxe has sold over 64 million copies, so making Mario Kart 9 a Switch 2 exclusive would be very enticing to attract players to the new machine. Adding more characters and tracks based on Nintendo’s other franchises would appeal to the masses there. Based on the development timelines of their internal studios, it seems Nintendo has been sitting on a goldmine of titles to launch during the Nintendo Switch 2’s launch window. Alongside Mario Kart, I expect to see a new 3D Mario, an upgraded Pokemon, and likely some other surprises in year one. Nintendo will pull out all the stops.

+

It is worth noting that it’s been almost five years since Animal Crossing. The inevitable announcement of a sequel to 2020's Animal Crossing: New Horizons, which has sold over 45 million copies and became a cultural zeitgeist, will mobilize cozy gamers in full force, too. A new Animal Crossing and Mario Kart would reactivate some of the consumers who played during lockdowns.

+

I think backward compatibility is important, too. It is what gamers – and younger ones in particular – have come to expect from the market. It is also what the competition has done with the Series X and PS5 generation. Nintendo would not want to alienate fans here.

+

What about third party studios?

+

Except for Ubisoft, many third-party publishers were late to the party with the original Switch, scared off by the Wii U’s underperformance. Things will be different for the Nintendo Switch 2, and third parties will get in on the ground floor. The Switch 2 offers up a springboard for third-party developers to extend the lifecycles of their game catalogs, promising engagement and revenue boosts for third-party developers big and small.

+

It will be an opportunity for EA, Ubisoft, and the like to extend the product life cycles of their older PS4- and Xbox One-era games. Speaking of which, Xbox and even PlayStation have been more to launching games on the Switch. I expect this will ramp up on the Switch 2 as these companies continue their off-platform strategies. I can already play Halo on my Steam Deck. I expect I’ll be able to play it on my Switch 2 one day, too.

+

Thank you for your time.

+

Did the reveal get you excited about the upcoming console launch? Let us know in the poll and voice your opinion in the comments below.

+
+ + +
How do you feel about the Nintendo Switch 2 after the reveal?
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+

As a reminder, the Nintendo Switch 2 will be fully revealed through a dedicated Direct showcase scheduled for April 2. Shortly afterward, hands-on Experience events will happen in key locations around the globe, following this schedule:

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Europe
ParisApril 4th – 6th
LondonApril 11th – 13th
MilanApril 25th – 27th
BerlinApril 25th – 27th
MadridMay 9th – 11th
AmsterdamMay 9th – 11th
North America
New YorkApril 4th – 6th
Los AngelesApril 11th – 13th
DallasApril 25th – 27th
TorontoApril 25th – 27th
Oceania
MelbourneMay 10th – 11th
Asia
Tokyo (Makuhari)April 26th – 27th
SeoulMay 31st – June 1st
Hong KongTo be announced
TaipeiTo be announced
+

Ticket registrations for the US events will begin on this web page in the near future.

+ + +
+ + +
+

Products mentioned

+
+ + +
+
Nintendo Switch
+
+

Nintendo Switch

+ USD 274.49 + Buy from Amazon +
+
+ + +
+
+ + + + + + + + +
+ + + +
+ +
+ + + +
+
+ + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + diff --git a/src/extractors/custom/index.js b/src/extractors/custom/index.js index 2cad53b..24b47a1 100644 --- a/src/extractors/custom/index.js +++ b/src/extractors/custom/index.js @@ -149,3 +149,4 @@ export * from './www.hardwarezone.com.sg'; export * from './www.spiegel.de'; export * from './mobilesyrup.com'; export * from './www.channelnewsasia.com'; +export * from './wccftech.com'; diff --git a/src/extractors/custom/wccftech.com/index.js b/src/extractors/custom/wccftech.com/index.js new file mode 100644 index 0000000..43d4591 --- /dev/null +++ b/src/extractors/custom/wccftech.com/index.js @@ -0,0 +1,30 @@ +export const WccftechComExtractor = { + domain: 'wccftech.com', + + title: { + selectors: [['meta[name="og:title"]', 'value']], + }, + + author: { + selectors: ['div.meta a:first-of-type'], + }, + + date_published: { + selectors: [ + ['meta[name="pub_date"]', 'value'], + ['meta[name="article:published_time"]', 'value'], + ], + }, + + lead_image_url: { + selectors: [['meta[name="og:image"]', 'value']], + }, + + content: { + selectors: ['.content'], + transforms: {}, + clean: [ + '.democracy', // JavaScript polls + ], + }, +}; diff --git a/src/extractors/custom/wccftech.com/index.test.js b/src/extractors/custom/wccftech.com/index.test.js new file mode 100644 index 0000000..b3b2ba9 --- /dev/null +++ b/src/extractors/custom/wccftech.com/index.test.js @@ -0,0 +1,77 @@ +import assert from 'assert'; +import URL from 'url'; +import cheerio from 'cheerio'; + +import Parser from 'mercury'; +import getExtractor from 'extractors/get-extractor'; +import { excerptContent } from 'utils/text'; + +const fs = require('fs'); + +describe('WccftechComExtractor', () => { + describe('initial test case', () => { + let result; + let url; + beforeAll(() => { + url = + 'https://wccftech.com/nintendo-switch-2-reveal-hit-all-the-right-notes-according-to-analyst/'; + const html = fs.readFileSync( + './fixtures/wccftech.com/1737405508147.html' + ); + result = Parser.parse(url, { html, fallback: false }); + }); + + it('is selected properly', () => { + const extractor = getExtractor(url); + assert.equal(extractor.domain, URL.parse(url).hostname); + }); + + it('returns the title', async () => { + const { title } = await result; + + assert.equal( + title, + `Nintendo Switch 2 Reveal Hit All the Right Notes, According to Analyst` + ); + }); + + it('returns the author', async () => { + const { author } = await result; + + assert.equal(author, 'Alessio Palumbo'); + }); + + it('returns the date_published', async () => { + const { date_published } = await result; + + assert.equal(date_published, `2025-01-17T20:00:30.000Z`); + }); + + it('returns the lead_image_url', async () => { + const { lead_image_url } = await result; + + assert.equal( + lead_image_url, + `https://cdn.wccftech.com/wp-content/uploads/2025/01/16x9-NintendoSwitch2-HD-scaled.jpg` + ); + }); + + it('returns the content', async () => { + const { content } = await result; + + const $ = cheerio.load(content || ''); + + const first13 = excerptContent( + $('*') + .first() + .text(), + 13 + ); + + assert.equal( + first13, + 'The Nintendo Switch 2 is finally official. After a couple of years of' + ); + }); + }); +});