How to check backlinks of a website

Authors: CodeToday | PHP Code | Views: 398 | Posted: 05 AM: 09/05/2017

How to check backlinks of a websiteThe backlinks of a website are very important for keyword SEO, it is the power of the website in many factors with SEO.
To check the backlinks of a website, you can enter google.com with the link:domain syntax.
This article will guide you how to check backlinks directly on the website through google.com









HTML

<form action="" method="post" class="form-horizontal">
<div class="form-group">
<input type="text" name="domain" id="domain" value="<?=$_POST['domain']?>" class="form-control" placeholder = "Enter domain here ..." required/>
</div>
<div class="form-group">
<button type="submit" name="submit" class="btn btn-info">Check Backlinks Now</button>
</div>
</form>

The domain received from this form will be send directly to the following url

https://www.google.com/search?num=20&q=link:'.$_POST['domain']

Note: You can change the number num =? (Maximum: 100)

PHP

<?
if(isset($_POST['submit'])){

$url       = 'https://www.google.com/search?num=20&q=link:'.$_POST['domain'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_HTTPGET, 1 );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1 );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1 );
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_REFERER, $ref );
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);     
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$html = curl_exec($ch);
curl_close($ch);

$regexp    = "<as[^>]*href=("??)([^" >]*?)1[^>]*>(.*)</a>";
if(preg_match_all("/$regexp/siU", $html, $matches, PREG_SET_ORDER)) {

	foreach($matches as $match) {  
		if(filter_var($match[2], FILTER_VALIDATE_URL)) { //Filter out valid urls
			if(stristr($match[2],'google')    == false &&
			   stristr($match[2],'search?q=') == false) {	
				 $urlLink[] = $match[2];   		 
			}		
		}
	}
}
print_r($urlLink);
}
?>


If you have any questions, please leave a message below