@@ -91,6 +91,11 @@ public function __construct(Request $request)
9191 $ icons [] = $ meta ->getAttribute ('content ' );
9292 continue 2 ;
9393
94+ case 'pub_date ' :
95+ case 'date ' :
96+ $ this ->set ('datepublished ' , $ meta ->getAttribute ('content ' ));
97+ continue 2 ;
98+
9499 default :
95100 if ($ meta ->hasAttribute ('content ' )) {
96101 $ this ->set ($ name , $ meta ->getAttribute ('content ' ));
@@ -99,12 +104,27 @@ public function __construct(Request $request)
99104 }
100105 }
101106
107+ if ($ meta ->hasAttribute ('itemprop ' )) {
108+ $ name = strtolower ($ meta ->getAttribute ('itemprop ' ));
109+ $ this ->set ($ name , $ meta ->getAttribute ('content ' ));
110+ }
111+
102112 if ($ meta ->hasAttribute ('http-equiv ' ) && $ meta ->hasAttribute ('content ' )) {
103113 $ name = strtolower ($ meta ->getAttribute ('http-equiv ' ));
104114 $ this ->set ($ name , $ meta ->getAttribute ('content ' ));
105115 }
106116 }
107117
118+ //Time
119+ foreach ($ html ->getElementsByTagName ('time ' ) as $ time ) {
120+ if ($ time ->hasAttribute ('itemprop ' )) {
121+ $ name = strtolower ($ time ->getAttribute ('itemprop ' ));
122+ $ this ->set ($ name , $ time ->getAttribute ('datetime ' ));
123+ } else if ($ time ->hasAttribute ('datetime ' )) {
124+ $ this ->set ('datepublished ' , $ time ->getAttribute ('datetime ' ));
125+ }
126+ }
127+
108128 //Search the main element:
109129 $ content = $ html ->getElementsByTagName ('main ' ); //<main> element
110130
@@ -280,4 +300,14 @@ public function getHeight()
280300 {
281301 return $ this ->get ('video_height ' );
282302 }
303+
304+ /**
305+ * Gets the article publication date
306+ *
307+ * @return string|null
308+ */
309+ public function getPublishedTime ()
310+ {
311+ return $ this ->get ('datepublished ' );
312+ }
283313}
0 commit comments