@@ -19,7 +19,7 @@ class HtmlPieces
1919 * @param string $element
2020 * @return string
2121 */
22- public function get (object $ page , string $ element )
22+ public function get (object $ page , string $ element, array $ options = [] )
2323 {
2424 // Initiate dom object
2525 // -> handles page scraping
@@ -87,13 +87,11 @@ public function get(object $page, string $element)
8787
8888 $ actorRow = $ castRow ->find ('td ' )[1 ];
8989 $ actorLink = $ actorRow ->find ('a ' );
90- if (count ($ actorLink ) > 0 )
91- {
90+ if (count ($ actorLink ) > 0 ) {
9291 // Set actor name to text within link
9392 $ actor ["actor " ] = $ actorLink ->text ;
9493 $ actor ["actor_id " ] = $ this ->extractImdbId ($ actorLink ->href );
95- } else
96- {
94+ } else {
9795 // No link found
9896 // Set actor name to whatever is there
9997 $ actor ["actor " ] = $ actorRow ->text ;
@@ -108,6 +106,24 @@ public function get(object $page, string $element)
108106 return $ cast ;
109107 break ;
110108
109+ case "technical_specs " :
110+ $ technical_specs = [];
111+ $ table = $ dom ->find ($ page , '.dataTable tr ' );
112+ if (count ($ table ) > 0 ) {
113+ foreach ($ table as $ row )
114+ {
115+ $ row_title = $ row ->find ('td ' )[0 ]->text (true );
116+ $ row_value = str_replace (" " , " <br> " , $ row ->find ('td ' )[1 ]->text (true ));
117+ $ row = [
118+ $ this ->strClean ($ row_title ),
119+ $ this ->strClean ($ row_value )
120+ ];
121+ array_push ($ technical_specs , $ row );
122+ }
123+ }
124+ return $ technical_specs ;
125+ break ;
126+
111127 default :
112128 return "" ;
113129 }
0 commit comments