Skip to content

Commit

Permalink
feat: added regex for sperating words
Browse files Browse the repository at this point in the history
  • Loading branch information
flavin27 committed Feb 4, 2024
1 parent a67d101 commit 2a884a7
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Scraper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ public function scrape_data(): array
{
$content = $this->fetchContent();



$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML($content);
Expand Down Expand Up @@ -106,10 +104,29 @@ public function getCardapioDia(int $dia): array
if (count($cardapio) === 0) {
return [];
}

$string = $this->addSpace($cardapio[$dia][4]);

$cardapio[$dia][4] = $string;
return $cardapio[$dia];
}

public function addSpace(string $string): string
{
$resultado = preg_replace('/(parboilizado)(arroz)/', '$1, $2', $string);

$stringCorrigida = preg_replace('/(integral)(feijão)/', '$1, $2', $resultado);

return $stringCorrigida;
}
}

$client = new Scraper();
$cardapio = $client->getCardapioDia(3);

var_dump($cardapio);





0 comments on commit 2a884a7

Please sign in to comment.