@@ -41,6 +41,7 @@ function detailOption($id, $option)
41
41
$ response = json_decode ($ response ->getBody (), true );
42
42
$ page_data ['copyright ' ] = $ response ['copyright ' ];
43
43
$ page_data ['attributionText ' ] = $ response ['attributionText ' ];
44
+ $ page_data ['option ' ] = $ option ;
44
45
$ multiDatas = $ response ['data ' ]['results ' ][0 ];
45
46
$ page_data ['comic ' ] = $ multiDatas ;
46
47
if (isset ($ multiDatas ['series ' ])) {
@@ -57,62 +58,62 @@ public function comicsCrawler()
57
58
$ response = $ client ->request ('GET ' , 'https://www.marvel.com/comics?&options%5Boffset%5D=0&totalcount=12 ' );
58
59
$ response = $ response ->getBody ()->getContents ();
59
60
60
- $ teste = Str::after ($ response , '<section class="module JMMultiRow moduColor_Light no-stripes" id="onsale"> ' );
61
- $ exibe1 = Str::before ($ teste , 'footer ' );
62
- $ keywords = preg_split ('/\s+v|<div class="row-item comic-item">\s+/i ' , $ exibe1 );
63
- $ totalColetado = 0 ;
64
- $ tituloGeral = array ();
61
+ $ pageStart = Str::after ($ response , '<section class="module JMMultiRow moduColor_Light no-stripes" id="onsale"> ' );
62
+ $ closePage = Str::before ($ pageStart , 'footer ' );
63
+ $ keywords = preg_split ('/\s+v|<div class="row-item comic-item">\s+/i ' , $ closePage );
64
+ $ totalCollected = 0 ;
65
+ $ generalTitle = array ();
65
66
foreach ($ keywords as $ k => $ v ) {
66
67
if (Str::contains ($ keywords [$ k ], '<h2 class="module-header"> ' )) {
67
68
$ idTituloGeral = $ k ;
68
- $ limpaTituloGeral1 = Str::after ($ keywords [$ k ], '<h2 class="module-header"> ' );
69
- $ limpaTituloGeral11 = Str::before ($ limpaTituloGeral1 , '< ' );
70
- $ tituloGeral [$ k ]['titulogeral ' ] = trim ($ limpaTituloGeral11 );
71
- $ tituloGeral [$ k ]['id ' ] = [];
72
- $ tituloGeral [$ k ]['url ' ] = [];
73
- $ tituloGeral [$ k ]['title ' ] = [];
74
- $ tituloGeral [$ k ]['imagem ' ] = [];
75
- $ tituloGeral [$ k ]['criadores ' ] = [];
69
+ $ startGeneralTitle = Str::after ($ keywords [$ k ], '<h2 class="module-header"> ' );
70
+ $ closeGeneralTitle = Str::before ($ startGeneralTitle , '< ' );
71
+ $ generalTitle [$ k ]['generalTitle ' ] = trim ($ closeGeneralTitle );
72
+ $ generalTitle [$ k ]['id ' ] = [];
73
+ $ generalTitle [$ k ]['url ' ] = [];
74
+ $ generalTitle [$ k ]['title ' ] = [];
75
+ $ generalTitle [$ k ]['image ' ] = [];
76
+ $ generalTitle [$ k ]['creators ' ] = [];
76
77
77
78
foreach ($ keywords as $ k => $ v ) {
78
79
if (Str::contains ($ keywords [$ k ], '<div class="row-item-image"> ' )) {
79
- $ limpaTituloComic1 = Str::after ($ keywords [$ k ], '<a href=" // ' );
80
- $ limpaTituloComic2 = Str::before ($ limpaTituloComic1 , '" class=" ' );
81
- array_push ($ tituloGeral [$ idTituloGeral ]['url ' ], trim ('https:// ' . $ limpaTituloComic2 ));
82
- $ totalColetado += 1 ;
80
+ $ startTitleComic = Str::after ($ keywords [$ k ], '<a href=" // ' );
81
+ $ closeTitleComic = Str::before ($ startTitleComic , '" class=" ' );
82
+ array_push ($ generalTitle [$ idTituloGeral ]['url ' ], trim ('https:// ' . $ closeTitleComic ));
83
+ $ totalCollected += 1 ;
83
84
84
85
85
- $ limpaTituloId1 = Str::after ($ limpaTituloComic2 , '/issue/ ' );
86
- $ limpaTituloId2 = Str::before ($ limpaTituloId1 , '/ ' );
87
- array_push ($ tituloGeral [$ idTituloGeral ]['id ' ], trim ($ limpaTituloId2 ));
86
+ $ startTitleId = Str::after ($ closeTitleComic , '/issue/ ' );
87
+ $ closeTitleId = Str::before ($ startTitleId , '/ ' );
88
+ array_push ($ generalTitle [$ idTituloGeral ]['id ' ], trim ($ closeTitleId ));
88
89
89
90
if (Str::contains ($ keywords [$ k ], '<p class="meta-creators"> ' )) {
90
- $ limpaCreatorsComic1 = Str::after ($ keywords [$ k ], '<p class="meta-creators"> ' );
91
- $ limpaCreatorsComic2 = Str::before ($ limpaCreatorsComic1 , '</p> ' );
92
- array_push ($ tituloGeral [$ idTituloGeral ]['criadores ' ], trim ($ limpaCreatorsComic2 ));
91
+ $ startCreatorsComic = Str::after ($ keywords [$ k ], '<p class="meta-creators"> ' );
92
+ $ closeCreatorsComic = Str::before ($ startCreatorsComic , '</p> ' );
93
+ array_push ($ generalTitle [$ idTituloGeral ]['creators ' ], trim ($ closeCreatorsComic ));
93
94
} else {
94
- array_push ($ tituloGeral [$ idTituloGeral ]['criadores ' ], 'Author Not Informed by Marvel ' );
95
+ array_push ($ generalTitle [$ idTituloGeral ]['creators ' ], 'Author Not Informed by Marvel ' );
95
96
}
96
97
97
98
if (Str::contains ($ keywords [$ k ], '<img src="https ' )) {
98
- $ limpaImagemComic1 = Str::after ($ keywords [$ k ], '<img src=" ' );
99
- $ limpaImagemComic2 = Str::before ($ limpaImagemComic1 , '" alt=" ' );
100
- array_push ($ tituloGeral [$ idTituloGeral ]['imagem ' ], trim ($ limpaImagemComic2 ));
99
+ $ startImageComic = Str::after ($ keywords [$ k ], '<img src=" ' );
100
+ $ closeImageComic = Str::before ($ startImageComic , '" alt=" ' );
101
+ array_push ($ generalTitle [$ idTituloGeral ]['image ' ], trim ($ closeImageComic ));
101
102
} else {
102
- array_push ($ tituloGeral [$ idTituloGeral ]['imagem ' ], 'Problema com Imagem - Comics ' );
103
+ array_push ($ generalTitle [$ idTituloGeral ]['image ' ], 'Problem with Image - Comics ' );
103
104
}
104
105
105
106
if (Str::contains ($ keywords [$ k ], '" alt=" ' )) {
106
- $ limpaTitleComic1 = Str::after ($ keywords [$ k ], '" alt=" ' );
107
- $ limpaTitleComic2 = Str::before ($ limpaTitleComic1 , '" title=" ' );
108
- array_push ($ tituloGeral [$ idTituloGeral ]['title ' ], trim ($ limpaTitleComic2 ));
107
+ $ startTitleComic = Str::after ($ keywords [$ k ], '" alt=" ' );
108
+ $ closeTitleComic = Str::before ($ startTitleComic , '" title=" ' );
109
+ array_push ($ generalTitle [$ idTituloGeral ]['title ' ], trim ($ closeTitleComic ));
109
110
} else {
110
- array_push ($ tituloGeral [$ idTituloGeral ]['title ' ], 'Problema com Título - Comics ' );
111
+ array_push ($ generalTitle [$ idTituloGeral ]['title ' ], 'Problema com Título - Comics ' );
111
112
}
112
113
}
113
114
}
114
115
}
115
116
}
116
- return view ('comicsCrawler ' , compact ('tituloGeral ' , 'totalColetado ' ));
117
+ return view ('comicsCrawler ' , compact ('generalTitle ' , 'totalCollected ' ));
117
118
}
118
119
}
0 commit comments