File tree Expand file tree Collapse file tree
fixtures/www.newyorker.com Expand file tree Collapse file tree Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -37,7 +37,10 @@ export const NewYorkerExtractor = {
3737 date_published : {
3838 selectors : [
3939 [ 'meta[name="article:published_time"]' , 'value' ] ,
40+ [ 'time[itemProp="datePublished"]' , 'content' ] ,
4041 ] ,
42+
43+ timezone : 'America/New_York' ,
4144 } ,
4245
4346 lead_image_url : {
@@ -48,6 +51,8 @@ export const NewYorkerExtractor = {
4851
4952 dek : {
5053 selectors : [
54+ '.dek' ,
55+ 'h2.dek' ,
5156 ] ,
5257 } ,
5358
Original file line number Diff line number Diff line change @@ -105,4 +105,33 @@ describe('NewYorkerExtractor', () => {
105105 // the article.
106106 assert . equal ( first13 , 'In a laboratory in Shanghai, researchers work on developing a quantum computer—a new' ) ;
107107 } ) ;
108+
109+ it ( 'returns the dek when present' , async ( ) => {
110+ const html =
111+ fs . readFileSync ( './fixtures/www.newyorker.com/1480713300334.html' ) ;
112+
113+ const url =
114+ 'http://www.newyorker.com/magazine/2016/12/05/lessons-from-my-mother' ;
115+
116+ const { dek } =
117+ await Mercury . parse ( url , html , { fallback : false } ) ;
118+
119+ assert . equal (
120+ dek ,
121+ 'I had a sense that she was a good teacher, but I had no idea that she was such an influential one, and in the very area I had chosen.'
122+ ) ;
123+ } ) ;
124+
125+ it ( 'returns the date for magazine content' , async ( ) => {
126+ const html =
127+ fs . readFileSync ( './fixtures/www.newyorker.com/1480713300334.html' ) ;
128+
129+ const url =
130+ 'http://www.newyorker.com/magazine/2016/12/05/lessons-from-my-mother' ;
131+
132+ const { date_published } =
133+ await Mercury . parse ( url , html , { fallback : false } ) ;
134+
135+ assert . equal ( date_published , '2016-11-28T05:00:00.000Z' ) ;
136+ } ) ;
108137} ) ;
You can’t perform that action at this time.
0 commit comments