@ 2014-09-14T16:58:03Z <?php
$url = 'https://secure.i-web.ch/dweb/uri/de/behoerdenmain/gerichtetop/rechtsprechung/?action=info&pubid=4762';
$site = getSiteContent($url);
// echo $site;
$linksArr = getDomLinks($site);
displayArray($linksArr);
exit;
function getSiteContent($url, $cookieFile = NULL)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function getDomLinks($contents)
{
$linkArr = array();
$dom = new domDocument;
@$dom->loadHTML($contents);
$links = $dom->getElementsByTagName('a');
foreach ($links as $tag)
{
$linkArr[$tag->getAttribute('href')] = $tag->childNodes->item(0)->nodeValue;
}
return $linkArr;
}
function displayArray($aArray) {
if (is_array($aArray) && (count($aArray) > 0)) {
print("<table border=1>");
print("<tr><th>Key</th><th>Value</th></tr>");
foreach ($aArray as $aKey => $aValue) {
print("<tr>");
if (!is_array($aValue)) {
if (empty($aValue)) {
print("<td>$aKey</td><td><i>$aValue</i></td>");
} else {
print("<td>$aKey</td><td>$aValue</td>");
}
} else {
print("<td>$aKey(array)</td><td>");
displayArray($aValue);
print("</td>");
}
print("</tr>");
}
print("</table>");
} else {
print("<i>empty or invalid</i>");
}
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.25 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/slLXK:15
Stack trace:
#0 /in/slLXK(5): getSiteContent('https://secure....')
#1 {main}
thrown in /in/slLXK on line 15
Process exited with code 255 . Output for 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.24 - 5.5.35 , 5.6.7 - 5.6.28 Fatal error: Call to undefined function curl_init() in /in/slLXK on line 15
Process exited with code 255 . Output for 4.4.2 - 4.4.9 Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/slLXK on line 38
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/slLXK on line 38
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error in /in/slLXK on line 38
Process exited with code 255 . preferences:dark mode live preview
238.71 ms | 401 KiB | 327 Q