From 65323169730dddf0ddc47da6b1119e1d62a3f99e Mon Sep 17 00:00:00 2001 From: Andrei Zhemaituk Date: Wed, 9 Nov 2022 14:37:36 -0500 Subject: [PATCH] custom parser for cbc.ca (#699) Co-authored-by: Andrei Zhemaituk Co-authored-by: Sarah Doire Co-authored-by: Sarah Doire --- fixtures/www.cbc.ca/1665765912229.html | 139 ++++++++++++++++++ src/extractors/custom/index.js | 1 + src/extractors/custom/www.cbc.ca/index.js | 36 +++++ .../custom/www.cbc.ca/index.test.js | 112 ++++++++++++++ 4 files changed, 288 insertions(+) create mode 100644 fixtures/www.cbc.ca/1665765912229.html create mode 100644 src/extractors/custom/www.cbc.ca/index.js create mode 100644 src/extractors/custom/www.cbc.ca/index.test.js diff --git a/fixtures/www.cbc.ca/1665765912229.html b/fixtures/www.cbc.ca/1665765912229.html new file mode 100644 index 00000000..c5053c11 --- /dev/null +++ b/fixtures/www.cbc.ca/1665765912229.html @@ -0,0 +1,139 @@ + + + + Housing market slowdown continues with sales and average prices well down from last year | CBC News + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Business·Updated

Housing market slowdown continues with sales and average prices well down from last year

New numbers from the Canadian Real Estate Association confirm what buyers, sellers and owners have known for a while: the housing market is in a funk.

Average price of a home that sold in September was $640,479

A house, for sale in Toronto’s Beaches neighbourhood, is shown. The average selling price of a Canadian home has declined by almost $200,000 since February, when this house was for sale. (Evan Mitsui/CBC)

New numbers from the Canadian Real Estate Association confirm what buyers, sellers and owners have known for a while: the housing market is in a funk.

The group that represents more than 155,000 Realtors across the country said in a release Friday that sales for September were down by more than 30 per cent compared to the same period a year ago.

Prices are down on an annual basis, too, with the average selling price of a home listed on the MLS system going for $640,479. That's down by 6.6 per cent compared to a year ago, and down by more than 21 per cent from the all-time high of $816,720 reached in February.

That was before the Bank of Canada began its aggressive campaign of rate hikes to rein in runaway inflation. The central bank has moved its benchmark lending rate up by more than three percentage points in the past six months, pushing rates on variable rate loans above five and even six per cent.

That's poured cold water on the once red-hot housing market.

"The important thing to remember is we're still in the middle of a period of rapid adjustment, with buyers and sellers trying to feel each other out while a lot of people have had to take their home search plans back to the drawing board," CREA's chief economist Shaun Cathcart said in a release. 

"As such, resale markets may remain on the quiet side for some time yet, with the flipside of that coin being even more pressure on rental markets."

Rental market is hot

That's the case in many markets across the country, including Brampton, Ont., where realtor Shaun Ghulam said he's noticed an interesting dichotomy: the market to own has cooled, but competition for rentals is red hot.

"Lease prices are ridiculous now," he said in an interview. "If it's $3,000 a month, people are coming in at $3,500."

A man, woman and a baby sit on a couch in a living room.
Earl Hypolite and Naomi Zitt-James rent an apartment in Toronto, but they say they are getting ready to buy, and most likely they will purchase a fixer-upper somewhere outside the downtown core. (Darek Zdzienicki/CBC)

That uncertainty in the rental market is one reason why Earl Hypolite and Naomi Zitt-James say they're looking to buy a house of their own, sooner rather than later. The couple rents an apartment in downtown Toronto, but with a seven-month-old baby and a large dog, they feel it's time to make the leap.

"When it was just the two of us, I think it was really appealing," Zitt-James said of renting. 

"But now to have that amount of money ... go into renting as opposed to paying down something that we own, it's a little bit more unappealing than it was when we first moved in."

While they have no imminent plans to buy, they have been looking at properties outside the city, where prices have come down a lot. 

"I'm feeling a lot better now that I know that the prices have come down a little bit," Zitt-James said. "I just feel a little sad for those people that went in and got those houses only to have it come down."

Realtor Ghulam said selling prices have declined considerably in Brampton since the spring. Sellers are still asking for prices they might have gotten six months ago, and when they don't get any offers, they delist their home and try again at a lower price, hoping to spark a bidding war that rarely comes.

"Check how many times the property has been listed," Ghulam said. "If it's been listed for four or five times, you know the seller is not serious to sell and they're just playing."

The result is a wide gap between seller expectations and those of buyers. "Sellers are holding off, they're waiting to see where the interest rates go," he said. "Buyers are a little hesitant because they want to wait until the prices drop more."

ABOUT THE AUTHOR

Pete Evans

Senior Business Writer

Pete Evans is the senior business writer for CBCNews.ca. Prior to coming to the CBC, his work has appeared in the Globe & Mail, the Financial Post, the Toronto Star, and Canadian Business Magazine. Twitter: @p_evans Email: pete.evans@cbc.ca

Add some “good” to your morning and evening.

A variety of newsletters you'll love, delivered straight to you.

Sign up now

Comments

To encourage thoughtful and respectful conversations, first and last names will appear with each submission to CBC/Radio-Canada's online communities (except in children and youth-oriented communities). Pseudonyms will no longer be permitted.

By submitting a comment, you accept that CBC has the right to reproduce and publish that comment in whole or in part, in any manner CBC chooses. Please note that CBC does not endorse the opinions expressed in comments. Comments on this story are moderated according to our Submission Guidelines. Comments are welcome while open. We reserve the right to close comments at any time.

Become a CBC Member

Join the conversation  Create account

Already have an account?

now
+ + + +
+ + \ No newline at end of file diff --git a/src/extractors/custom/index.js b/src/extractors/custom/index.js index b91c2429..8c34ffae 100644 --- a/src/extractors/custom/index.js +++ b/src/extractors/custom/index.js @@ -143,3 +143,4 @@ export * from './arstechnica.com'; export * from './www.ndtv.com'; export * from './www.spektrum.de'; export * from './postlight.com'; +export * from './www.cbc.ca'; diff --git a/src/extractors/custom/www.cbc.ca/index.js b/src/extractors/custom/www.cbc.ca/index.js new file mode 100644 index 00000000..61c10090 --- /dev/null +++ b/src/extractors/custom/www.cbc.ca/index.js @@ -0,0 +1,36 @@ +export const WwwCbcCaExtractor = { + domain: 'www.cbc.ca', + + title: { + selectors: ['h1'], + }, + + author: { + selectors: ['.authorText', '.bylineDetails'], + }, + + date_published: { + selectors: [['.timeStamp[datetime]', 'datetime']], + }, + + dek: { + selectors: ['.deck'], + }, + + lead_image_url: { + selectors: [['meta[name="og:image"]', 'value']], + }, + + content: { + selectors: ['.story'], + + // Is there anything in the content you selected that needs transformed + // before it's consumable content? E.g., unusual lazy loaded images + transforms: {}, + + // Is there anything that is in the result that shouldn't be? + // The clean selectors will remove anything that matches from + // the result + clean: [], + }, +}; diff --git a/src/extractors/custom/www.cbc.ca/index.test.js b/src/extractors/custom/www.cbc.ca/index.test.js new file mode 100644 index 00000000..95657ed8 --- /dev/null +++ b/src/extractors/custom/www.cbc.ca/index.test.js @@ -0,0 +1,112 @@ +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('WwwCbcCaExtractor', () => { + describe('initial test case', () => { + let result; + let url; + beforeAll(() => { + url = 'https://www.cbc.ca/news/business/crea-september-numbers-1.6616369'; + const html = fs.readFileSync('./fixtures/www.cbc.ca/1665765912229.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.cbc.ca/index.js. + const { title } = await result; + + // Update these values with the expected values from + // the article. + assert.equal( + title, + `Housing market slowdown continues with sales and average prices well down from last year` + ); + }); + + it('returns the author', async () => { + // To pass this test, fill out the author selector + // in ./src/extractors/custom/www.cbc.ca/index.js. + const { author } = await result; + + // Update these values with the expected values from + // the article. + assert.equal(author, `Pete Evans`); + }); + + it('returns the date_published', async () => { + // To pass this test, fill out the date_published selector + // in ./src/extractors/custom/www.cbc.ca/index.js. + const { date_published } = await result; + + // Update these values with the expected values from + // the article. + assert.equal(date_published, '2022-10-14T16:20:52.800Z'); + }); + + it('returns the dek', async () => { + // To pass this test, fill out the dek selector + // in ./src/extractors/custom/www.cbc.ca/index.js. + const { dek } = await result; + + // Update these values with the expected values from + // the article. + assert.equal( + dek, + 'Average price of a home that sold in September was $640,479' + ); + }); + + it('returns the lead_image_url', async () => { + // To pass this test, fill out the lead_image_url selector + // in ./src/extractors/custom/www.cbc.ca/index.js. + const { lead_image_url } = await result; + + // Update these values with the expected values from + // the article. + assert.equal( + lead_image_url, + `https://i.cbc.ca/1.6616381.1665753066!/fileImage/httpImage/image.JPG_gen/derivatives/16x9_620/real-estate-sign.JPG` + ); + }); + + it('returns the content', async () => { + // To pass this test, fill out the content selector + // in ./src/extractors/custom/www.cbc.ca/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, + 'New numbers from the Canadian Real Estate Association confirm what buyers, sellers and' + ); + }); + }); +});