// Pega pagina $crawler = $this->goutte->request('GET', $url); // Pega informaçoes da pagina $data = array(); foreach ($website['scan'] as $key => $filter) { $str = strip_tags($crawler->filterXPath($filter)->text()); $str = preg_replace($this->stop_words, "", $str); $data[$key] = $str; } // coloca na lista de resultados $this->result[$website['name']][] = $data; } } /** * Salva resultados em json * * @param null $dir */ public function save($dir = null) { if (is_null($dir)) { $dir = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "json"; } foreach ($this->result as $entry => $data) { file_put_contents($dir . DIRECTORY_SEPARATOR . $entry . ".json", json_encode($data)); } } } $sp = new Spider(); $sp->run(); $sp->save();