request('GET', $url); $html = (string) $response->getBody(); $document = new Document($html); $links = $document->find('.miasta > li > a::attr(href)'); foreach($links as $link) { $url = $base . $link; $response = $client->request('GET', $url); $html = (string) $response->getBody(); $document = new Document($html); $emails = $document->find('.email > a::attr(href)'); if (!empty($emails)) { echo str_replace("mailto:", "", $emails[0]) . "\n"; } }