Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking up on a link exchange

I have made a link exchange with another site. 3 days later, the site has removed my link.

Is there a simple php script to help me control link exchanges and notify me if my link has been removed?

I need it as simple as possible, and not a whole ad. system manager.

like image 772
yarek Avatar asked Jan 27 '26 06:01

yarek


1 Answers

If you know the URL of webpage where your ad(link) exists then you can use Simple HTML DOM Parser to get all links of that webpage in array and then use php in_array function to check that your link exists in that array or not. You can run this script on daily bases using crontab.

// Create DOM from URL
$html = file_get_html('http://www.example.com/');

// Find all links 
$allLinks = array();
foreach($html->find('a') as $element) {
    $allLinks[] =  $element->href;
}

// Check your link. 
$adLink = "http://www.mylink.com";
if ( in_array($adLink , $allLinks ) ) {
    echo "My link exists.";
} else {
    echo "My link is removed.";
}
like image 149
Naveed Avatar answered Jan 29 '26 20:01

Naveed