/** * doScraping Paging * @param $id * @param $pageNo * @return array */ function doScrapingPaging($id, $pageNo) { $url = $this->_url . $id . "/member/?page={$pageNo}"; $mapping = $this->getMapping(); $crawler = $this->getCrawler('GET', $url); if (is_null($crawler)) { return []; } $data = $this->scraping($crawler, $mapping); return Utils::swapArray($data); }
/** * doScraping (override) * @param $id * @return array */ function doScraping($id) { $url = $this->_url; $mapping = $this->getMapping(); $crawler = $this->getCrawler('GET', $url); if (is_null($crawler)) { return []; } $data = $this->scraping($crawler, $mapping); return Utils::swapArray($data); }
/** * @param $node \Symfony\Component\DomCrawler\Crawler * @param string $attr * @param $trim * @return string */ public function getValue($node, $attr, $trim) { $temp = ''; try { if (Utils::isBlank($attr)) { $temp = $node->text(); } else { $temp = $node->attr($attr); } } catch (\Exception $e) { } if ($trim == 'timestamp') { $temp = preg_replace('/.*ldst_strftime\\(/', '', $temp); $temp = preg_replace('/,.*/', "", $temp); $temp = trim($temp); } if ($trim == 'hash') { preg_match('/([0-9a-zA-Z]+)$/', $temp, $m); $temp = trim($m[0]); } return Utils::trimQsa($temp); }
/** * @cover Lodestone\Utils::toSnakeCase */ public function testUtilsToSnakeCase_CamelCaseの場合_camel_caseが返る() { $this->assertEquals('camel_case', Utils::toSnakeCase('CamelCase')); }
public function testApiAbstract_scrapingのmappingが空の時_HTMLを取得する() { $mock = new ApiMock(); $crawler = $mock->getCrawler('GET', $this->url . $this->id); $this->assertTrue(!Utils::isBlank($mock->scraping($crawler, []))); }