HostJob.php
908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace app\jobs;
use Yii;
use PHPHtmlParser\Dom;
use app\components\Collection;
use yii\base\BaseObject;
use \yii\queue\JobInterface;
class HostJob extends BaseObject implements JobInterface
{
    //yii queue/listen -v --color
    // https://github.com/paquettg/php-html-parser
    public $host;
    public $grabSource;
    public function execute($queue)
    {
        echo $this->host;
        $result = Collection::getRawData($this->grabSource, $this->host);
        if (!$result['errorno']) {//без ошибок
            $dom = new Dom;
            $dom->loadStr($result['data']);
            $table = $dom->getElementById('#resultcontainer');
            if ($table) {
              $td = $table->find('td');
              foreach ($td as $t) {
                 echo $t->text."\n";
              }
            }
          //  echo $a->text;
        }
        return null;
    }
}