setName('marine'); // argument 0 is the command name $command->addArgument(1); $command->setExecuteCallback( function (InputInterface $input, OutputInterface $output) { $ship_id = $input->getArgument(1); $url = $this->getVesselUrl($ship_id); $dom = new Dom; $dom->loadFromUrl($url); $html = $dom->find( ".column.vfix-top.npr table tbody" ); $out = []; foreach ($html as $inner_elem) { $elem_dom = new Dom(); $item = $elem_dom->loadStr($inner_elem); $out = ''; $index = 0; while ($data = $item->find('tr td', $index)) { $value = $item->find('tr td', $index+1)->innerHtml(); $out .= strip_tags($data->innerHtml()) . ': ' . strip_tags($value) . ' '; $index += 2; } $output->writeLn(rtrim($out)); } return Command::SUCCESS; } ); return [$command]; } private function getVesselUrl(string $ship_id): string { return "https://www.vesselfinder.com/vessels/" . $ship_id; } }