php - cURL doesn't work inside the function -
have such code:
<?php include_once('simple_html_dom.php'); function parseinit($url) { $ch = curl_init(); $timeout = 0; curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_ssl_verifyhost, 2); curl_setopt($ch, curlopt_followlocation, 1); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_connecttimeout, $timeout); $data = curl_exec($ch); curl_close($ch); $html = new simple_html_dom(); $data = $html->load($data); return $data; } function get_category($link) { $html = parseinit($link); $cat_view = $html->find(".category-view"); $cat_view_array = $html->find(".category"); if (isset($cat_view)) { echo "<ul>"; foreach ($cat_view_array $cat_block) { $cat_link = $cat_block->find("h2 a", 0)->href; echo "<li>".$cat_link."</li>"; get_category($cat_link); } echo "</ul>"; } else { return; } } get_category("https://www.smile-dental.de/index.php?option=com_virtuemart&view=virtuemart"); // example link ?>
i'm trying category links (and nested links) using curl initialization inside function, result "web page not available". (for example) if not use function get_category @ , (for testing) output links of first level (without recursion), won't errors. me , explain problem is?
thanks in advance!
Comments
Post a Comment