Using PHP to check Yahoo Links

Status
Not open for further replies.

Goldie Dice

Procrasti-nation
Aug 28, 2008
60
0
0
Hello Guys,

Am fairly experienced in PHP but I seem to have found a stumbling block for a new project.

I basically need a method to check how many Yahoo links a certain link has using PHP.

Is there an API or something that can be used to tap into this information easily or will I have to hire out a cURL expert?

Thanks.
 


No need in hiring out someone for this, just ask the right person.

Rename the below script get_yahoo_links.php and upload it to your server.

Use the script by doing something like

hxxp://www.domain.com/get_yahoo_links.php?link=all&url=wickedfire.com
^^ this returns all links to the given domain

hxxp://www.domain.com/get_yahoo_links.php?link=index&url=wickedfire.com
^^ this returns just the links to the homepage (useful when figuring deep links)

PHP:
<?php

$domain = 'www.' . urldecode($_GET['url']) ;

if ($_GET['link'] === 'all') {
  $links = total_links($domain) ;
  echo $links ;
} else {
  $links = homepage_links($domain) ;
  echo $links ;
}

function total_links($domain) {
  global $yahoo_id ;
  $this_query = 'https://siteexplorer.search.yahoo.com/advsearch?p=http%3A%2F%2F' . $domain . '&bwm=i&bwmo=d&bwmf=s' ;
  $text = file_get_the_contents($this_query) ;
  $links = (int) (str_replace(',','',strip_tags(get_explode('Inlinks (',')',$text)))) ;
  return $links ;
}

function homepage_links($domain) {
  global $yahoo_id ;
  $this_query = 'https://siteexplorer.search.yahoo.com/advsearch?p=http%3A%2F%2F' . $domain . '&bwm=i&bwmo=d&bwmf=u' ;
  $text = file_get_the_contents($this_query) ;
  $links = (int) (str_replace(',','',strip_tags(get_explode('Inlinks (',')',$text)))) ;
  return $links ;
}

function file_get_the_contents($url) {
  $ch = curl_init();
  $timeout = 10; // set to zero for no timeout
  curl_setopt ($ch, CURLOPT_URL, $url);
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  $file_contents = curl_exec($ch);
  curl_close($ch);
  return $file_contents;
}

function get_explode($first,$last,$text) {
  $array1 = explode($first,$text) ;
  $array2 = explode($last,$array1[1]) ;
  $output = $array2[0] ;
  return $output ;
}
?>
This is just some straight up scaping, no api or "code is poetry" horseshit. I've found that the api returns different results anyways.

Now post us some boobies!
 
Thanks a lot for this, fantastic!

I'm having problems using it on more than one domain, if I use it say 100 times on the same page it returns all with 0

Not sure if this is a timeout issue or what but am sure I will figure it out, thanks alot.

54lr6.jpg
 
Status
Not open for further replies.