File tree 3 files changed +62
-0
lines changed
fixtures/www.newyorker.com
3 files changed +62
-0
lines changed 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 = {
37
37
date_published : {
38
38
selectors : [
39
39
[ 'meta[name="article:published_time"]' , 'value' ] ,
40
+ [ 'time[itemProp="datePublished"]' , 'content' ] ,
40
41
] ,
42
+
43
+ timezone : 'America/New_York' ,
41
44
} ,
42
45
43
46
lead_image_url : {
@@ -48,6 +51,8 @@ export const NewYorkerExtractor = {
48
51
49
52
dek : {
50
53
selectors : [
54
+ '.dek' ,
55
+ 'h2.dek' ,
51
56
] ,
52
57
} ,
53
58
Original file line number Diff line number Diff line change @@ -105,4 +105,33 @@ describe('NewYorkerExtractor', () => {
105
105
// the article.
106
106
assert . equal ( first13 , 'In a laboratory in Shanghai, researchers work on developing a quantum computer—a new' ) ;
107
107
} ) ;
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
+ } ) ;
108
137
} ) ;
You can’t perform that action at this time.
0 commit comments