PHP Function to count no. of yahoo backlinks
I am using this code to check but not getting result. Here I am trying to get backlinks of google.com in yahoo.
$url = "http://www.google.com";
$page = file_get_contents("http://siteexplorer.search.yahoo.com/search?p=$url&bwm=i开发者_StackOverflow社区&bwmf=a&bwms=p");
$expression = '/<span class="btn">Inlinks \((.*)\)<i class="tl"><\/i>/Us';
preg_match($expression, $page, $matches);
print_r($matches);
If you take a look at the source, there's no <i class="tl"></i>
after Inlinks (...)
. Which itself sums up pretty fine why regular expressions are a terrible tool for these kind of things in the first place. Nevertheless, it should work if you use the following expression:
$expression = '/<span class="btn">Inlinks \((.*)\)/';
精彩评论