我已经和另一个网站进行了链接交换。3天后,该网站删除了我的链接。
有没有一个简单的php脚本可以帮助我控制链接交换,并在我的链接被删除时通知我?
我需要它尽可能简单,而不是整个广告。系统管理员。
发布于 2010-10-06 01:20:57
如果您知道您的广告(链接)所在网页的URL,那么您可以使用Simple HTML DOM Parser在数组中获取该网页的所有链接,然后使用php in_array函数检查您的链接是否存在于该数组中。您可以使用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.";
}发布于 2010-10-06 01:17:14
从技术上讲,没有办法知道某人的网站是否有链接到你的网站,除非你有来自他们网站的流量,或者你看了他们的网站。
你最好的选择是:
这是一个脚本,每次链接到你的图像时都会记录。通过混合使用PHP和.htaccess,这非常简单。
.htaccess:
RewriteRule path/to/myImage.jpg path/to/myScript.php
myScript.php:
/* Record (database, file, or however) that they accessed */
header("Content-type: image/jpeg");
echo file_get_contents("path/to/myImage.jpg");或者一个脚本,它每隔X分钟/小时/天查看他们的网站,并在返回的HTML中搜索指向您的图像的链接。这里的挑战是让脚本定期运行。这可以使用crontab或类似的命令来完成
myScript.php:
$html = file_get_contents("http://www.theirsite.com");
if(strpos($html, 'path/to/myImage.jpg') !== FALSE)
/* Happiness */
else
/* ALERT! */https://stackoverflow.com/questions/3866016
复制相似问题