| @@ 52-79 (lines=28) @@ | ||
| 49 | * |
|
| 50 | * @return array |
|
| 51 | */ |
|
| 52 | public function scraping() |
|
| 53 | { |
|
| 54 | $scrapped = []; |
|
| 55 | ||
| 56 | $this->hasError(); |
|
| 57 | ||
| 58 | foreach ($this->selectors as $name => $selector) { |
|
| 59 | if (is_string($selector)) { |
|
| 60 | $node = $this->scrap($selector); |
|
| 61 | ||
| 62 | if ($node->count()) { |
|
| 63 | $scrapped[$name] = $this->clearString($node->text()); |
|
| 64 | } |
|
| 65 | } elseif (is_array($selector)) { |
|
| 66 | foreach ($selector as $selector => $repeat) { |
|
| 67 | $node = $this->scrap($selector); |
|
| 68 | if ($node->count()) { |
|
| 69 | foreach ($node->filter($repeat) as $loop) |
|
| 70 | { |
|
| 71 | $scrapped[$name][] = $this->clearString($loop->nodeValue); |
|
| 72 | } |
|
| 73 | } |
|
| 74 | } |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| 78 | return $scrapped; |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * Limpa o valor repassado |
|
| @@ 64-91 (lines=28) @@ | ||
| 61 | * |
|
| 62 | * @return array |
|
| 63 | */ |
|
| 64 | public function scraping() |
|
| 65 | { |
|
| 66 | $scrapped = []; |
|
| 67 | ||
| 68 | $this->hasError(); |
|
| 69 | ||
| 70 | foreach ($this->selectors as $name => $selector) { |
|
| 71 | if (is_string($selector)) { |
|
| 72 | $node = $this->scrap($selector); |
|
| 73 | ||
| 74 | if ($node->count()) { |
|
| 75 | $scrapped[$name] = $this->clearString($node->text()); |
|
| 76 | } |
|
| 77 | } elseif (is_array($selector)) { |
|
| 78 | foreach ($selector as $selector => $repeat) { |
|
| 79 | $node = $this->scrap($selector); |
|
| 80 | if ($node->count()) { |
|
| 81 | foreach ($node->filter($repeat) as $loop) |
|
| 82 | { |
|
| 83 | $scrapped[$name][] = $this->clearString($loop->nodeValue); |
|
| 84 | } |
|
| 85 | } |
|
| 86 | } |
|
| 87 | } |
|
| 88 | } |
|
| 89 | ||
| 90 | return $scrapped; |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * Limpa o valor repassado |
|