Jump to content

Simple PHP Cloaked Link Checker


mki

Recommended Posts

Note: This is intended to be used in the Command Line Interface and you can't hardcode the URL without bug fixing it.

<?php

//Curl as Googlebot, intended for CLI

$requestUrl = ""; //hardcode the URL if desired

if (($argc<2) && ($requestUrl == "")){
	die("Usage: program URL\n");
}else{
	$requestUrl = $argv[1];
}

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $requestUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');

$output = curl_exec($ch);

curl_close($ch);

//dump the links to the console
$dom = new DOMDocument;

@$dom->loadHTML($output);

$links = $dom->getElementsByTagName('a');

foreach ($links as $link){
	echo $link->nodeValue . " : ";
	echo $link->getAttribute('href') . "\n";
}


?>
Link to comment
Share on other sites


SEOPress WordPress SEO plugin

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.