This is my code:
$curl = curl_init('http://www.houseoffraser.co.uk/');
$userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13";
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT ,0);
curl_setopt($curl, CURLOPT_USERAGENT, $userAgent);
curl_setopt($curl, CURLOPT_TIMEOUT, 400);
ini_set('max_execution_time', 300);
$page = curl_exec($curl);
if(curl_errno($curl)) // check for execution errors
{
echo 'Scraper error: ' . curl_error($curl);
exit;
}
$html= curl_close($curl);
$dom = new DOMDocument();
@$dom->loadHTML($html);
$regex = '/<nav class="hof-buttons">(.*?)<\/nav>/s';
if (preg_match($regex, $page, $list)) {
echo preg_replace("/<\\/?a(\\s+.*?>|>)/", "", $list[0])."<br />";
} else {
print "Not found";
}
I tried to get only the url name from the div tag. But it only gives me error. I want something like this in the main:
<div class="a"><a href="abc.php">a linki</a></div>
and in the codes it must be something like this:
if ( preg_match($regex, $page, $list) ){};
echo <a href="$list[1]"> $list[0]</a>;
But when I use this, it gives me error or no array. I want to have a code like that but how can I add what I want into the preg_match or how can I call the links in the div?