public function buildResponse(Crawler $responseCrawler) { $response = new CharacterSearchResponse(); $response->setPage($this->getPage())->setTotalResults($responseCrawler->filter('div.pager .pagination span.total')->first()->extract('_text', true)); foreach ($responseCrawler->filter('.area_inner_body .table_black_border_bottom table tr ') as $searchResult) { $searchResultCrawler = new Crawler($searchResult); $character = new CharacterSearchResult(); $loadUrl = $searchResultCrawler->filter('.player_name_area a')->extract('href', true); $characterName = $searchResultCrawler->filter('.player_name_area a')->extract('_text', true); $characterWorld = $searchResultCrawler->filter('.player_name_area span[class!="right_txt"]')->extract('_text', true); $languages = $searchResultCrawler->filter('.player_name_area span[class="right_txt"]')->extract('_text', true); $classImageUrl = $searchResultCrawler->filter('.ic_class img')->extract('src', true); $thumbnail = $searchResultCrawler->filter('.thumb_cont_black_50 img')->extract('src', true); $character->setId(preg_replace('/[^0-9]/i', '', $loadUrl))->setName($characterName)->setWorld(str_replace(array(')', '('), null, $characterWorld))->setLanguages(explode(',', $languages))->setThumbnail($thumbnail); //->setClass($classImageUrl); $response->addResult($character); } return $response; }
public function buildResponse(Crawler $responseCrawler) { $response = new CharacterSearchResponse(); $response->setPage($this->getPage())->setTotalResults($responseCrawler->filter('div.pager .pagination span.total')->first()->extract('_text', true)); $freeCompanyName = $responseCrawler->filter('.ic_freecompany_box .pt4 a')->extract('_text', true); foreach ($responseCrawler->filter('.area_inner_body .table_black_border_bottom table tr ') as $searchResult) { $searchResultCrawler = new Crawler($searchResult); $character = new CharacterSearchResult(); $loadUrl = $searchResultCrawler->filter('.player_name_area a')->extract('href', true); $characterName = $searchResultCrawler->filter('.player_name_area a')->extract('_text', true); $characterWorld = $searchResultCrawler->filter('.player_name_area span[class!="right_txt"]')->extract('_text', true); $classImageUrl = $searchResultCrawler->filter('.ic_class img')->extract('src', true); $thumbnail = $searchResultCrawler->filter('.thumb_cont_black_50 img')->extract('src', true); $fcRank = $searchResultCrawler->filter('.fc_member_status')->extract('_text', true); $grandCompany = explode('/', trim($searchResultCrawler->filter('.ic_gc')->extract('_text', true))); $classLevel = $searchResultCrawler->filter('.lv_class')->extract('_text'); if (is_array($classLevel)) { $classLevel = implode(',', $classLevel); } $character->setId(preg_replace('/[^0-9]/i', '', $loadUrl))->setName($characterName)->setWorld(str_replace(array(')', '('), null, $characterWorld))->setThumbnail($thumbnail)->setFreeCompany($freeCompanyName)->setFreeCompanyRank(trim($fcRank))->setCurrentClassLevel($classLevel)->setCurrentClassImage($classImageUrl)->setGrandCompany(isset($grandCompany[0]) ? $grandCompany[0] : null)->setGrandCompanyRank(isset($grandCompany[1]) ? $grandCompany[1] : null); $response->addResult($character); } return $response; }