@@ -31,33 +31,29 @@ class GoComicsBridge extends BridgeAbstract
3131 public function collectData ()
3232 {
3333 $ link = $ this ->getURI ();
34+ $ landingpage = getSimpleHTMLDOM ($ link );
35+
36+ $ link = $ landingpage ->find ('div[data-post-url] ' , 0 )->getAttribute ('data-post-url ' );
3437
3538 for ($ i = 0 ; $ i < $ this ->getInput ('limit ' ); $ i ++) {
3639 $ html = getSimpleHTMLDOM ($ link );
37- // get json data from the first page
38- $ json = $ html ->find ('div[class^="ShowComicViewer_showComicViewer__comic__"] script[type="application/ld+json"] ' , 0 )->innertext ;
39- $ data = json_decode ($ json , false );
40-
41- $ item = [];
4240
43- $ author = $ data ->author ->name ;
44- $ imagelink = $ data ->contentUrl ;
45- $ date = $ data ->datePublished ;
46- $ title = $ data ->name . ' - GoComics ' ;
47-
48- // get a permlink for this day's comic if there isn't one specified
49- if ($ link === $ this ->getURI ()) {
50- $ link = $ this ->getURI () . '/ ' . DateTime::createFromFormat ('F j, Y ' , $ date )->format ('Y/m/d ' );
51- }
41+ $ imagelink = $ html ->find ('meta[property="og:image"] ' , 0 )->content ;
42+ $ parts = explode ('/ ' , $ link );
43+ $ date = DateTime::createFromFormat ('Y/m/d ' , implode ('/ ' , array_slice ($ parts , -3 )));
44+ $ title = $ html ->find ('meta[property="og:title"] ' , 0 )->content ;
45+ preg_match ('/by (.*?) for/ ' , $ title , $ authormatches );
46+ $ author = $ authormatches [1 ] ?? 'GoComics ' ;
5247
48+ $ item = [];
5349 $ item ['id ' ] = $ imagelink ;
5450 $ item ['uri ' ] = $ link ;
5551 $ item ['author ' ] = $ author ;
5652 $ item ['title ' ] = 'GoComics ' . $ this ->getInput ('comicname ' );
5753 if ($ this ->getInput ('date-in-title ' ) === true ) {
5854 $ item ['title ' ] = $ title ;
5955 }
60- $ item ['timestamp ' ] = DateTime:: createFromFormat ( ' F j, Y ' , $ date) ->setTime (0 , 0 , 0 )->getTimestamp ();
56+ $ item ['timestamp ' ] = $ date ->setTime (0 , 0 , 0 )->getTimestamp ();
6157 $ item ['content ' ] = '<img src=" ' . $ imagelink . '" /> ' ;
6258
6359 $ link = rtrim (self ::URI , '/ ' ) . $ html ->find ('a[class*="ComicNavigation_controls__button_previous__"] ' , 0 )->href ;
0 commit comments