以编程方式检查远程网站“显示”特定的html元素

I want to require my free users to add a linkback to my website. But, I want to check it programmatically that indeed they added the linkback html element I provided and was not hidden by some sort of CSS and Javascript.

Any good suggestions?

Not an expert on this matter but I'd say the easiest and most reliable method involves actually rendering their page in a browser to ensure that all CSS and JavaScript is applied in the same way a user would see.

Obviously you don't want to do this yourself, but I assume your site has a page where users tell you that they've added the link to it, or where they request free usage based on that link. At this point you could load their page into a hidden IFrame then use JavaScript (JQuery would undoubtedly be easiest) to find your link and query its visibility.

This may be complicated by cross-domain security issues (accessing the IFrame's content) but a proxy on your server could easily work around this.

Without using a browser and JavaScript I can imagine it would be a huge job to parse their HTML, CSS and JavaScript server-side and look for any hint that your link isn't visible - as there are plenty of ways it could be hidden (even by accident).

$my_link = '<a href="http://www.myamazingsite.com/" title="Magic Stuff">Total Amazing Magic Tricks</a>';
$remote_html = file_get_contents('http://www.remotesite.com/some-amazing-page.php');
if(strpos($remote_html, $my_link) === false){
    // link was not found
}

You WON'T be able to easily tell if the link is hidden by CSS or JS unless you have enough computing power and programming knowledge to setup a simulation.