function remove_hidden_html_tag($html, $tag)
{
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML($html);
$node = $dom->documentElement;
if ($node === null) return html;
$dom_node_list = $node->getElementsByTagName($tag);
$i = 0;
while ($i < $dom_node_list->length)
{
if (strpos($dom_node_list->item($i)->getAttribute('style'), "display:none") !== false ||
strpos($dom_node_list->item($i)->getAttribute('style'), "visibility:hidden") !== false)
{
$dom_node_list->item($i)->parentNode->removeChild($dom_node_list->item($i));
$dom_node_list = $node->getElementsByTagname($tag);
$i=0;
}
else
$i++;
}
$html = $dom->saveHTML();
return $html;
}
$curl = curl_init("httt://www.websitename.com");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$html = curl_exec($curl);
curl_close($curl);
$html = remove_hidden_html_tag($html, 'div');