jigen7 Posted September 11, 2007 Share Posted September 11, 2007 i have here a function that returns the number of total websites that was being link to a certain site using the yahoo linkdomain:domain.com - site:domain.com, the problem is I also want to save those url into a some kind of variable for example an array so that i can echo/print them if i want them anybody who has an idea?? function yahoo_linkdomain($url){ $site = fopen('http://search.yahoo.com/search?ei=UTF-8&fr=sexp-rd&p=linkdomain%3A'.urlencode($url).'+-site%3A'.urlencode($url),'r'); while($cont = fread($site,1024657)){ $total .= $cont; } fclose($site); $match_expression = '/about (.*) for/Us'; preg_match($match_expression,$total,$matches); return $matches[1]; } Link to comment https://forums.phpfreaks.com/topic/68930-solved-helpsaving-generated-web-search-result-by-yahoo-using-linkdomain/ Share on other sites More sharing options...
kireol Posted September 12, 2007 Share Posted September 12, 2007 I would change the function. Instead of counting what you are currently matching on....I would preg match on a URL, then return an array of the URLs. Then you could call count($foundurls) to get the number and still have the urls stored too. Link to comment https://forums.phpfreaks.com/topic/68930-solved-helpsaving-generated-web-search-result-by-yahoo-using-linkdomain/#findComment-346584 Share on other sites More sharing options...
jigen7 Posted September 12, 2007 Author Share Posted September 12, 2007 could you help me construct a syntax like that?i dont know how to use preg match... Link to comment https://forums.phpfreaks.com/topic/68930-solved-helpsaving-generated-web-search-result-by-yahoo-using-linkdomain/#findComment-346588 Share on other sites More sharing options...
kireol Posted September 12, 2007 Share Posted September 12, 2007 I dont use preg_match, even though I should. my way would work but is uhhh, unorthidox but it would look something like unction yahoo_linkdomain($url){ $site = fopen('http://search.yahoo.com/search?ei=UTF-8&fr=sexp-rd&p=linkdomain%3A'.urlencode($url).'+-site%3A'.urlencode($url),'r'); while($cont = fread($site,1024657)){ $total .= $cont; } fclose($site); $urls = array(); while(1) { $total = strstr($total, "http://"); if(!$total) { break; } $endpos = strpos($total,"'"); $thelink= substr($total,0,$endpos); array_push($urls, $thelink); } return($urls); } My jenky code is basically what preg_match does except preg_match is way more efficient. but mine is a good exercise in learning what it preg_match does on a basic level Link to comment https://forums.phpfreaks.com/topic/68930-solved-helpsaving-generated-web-search-result-by-yahoo-using-linkdomain/#findComment-346592 Share on other sites More sharing options...
jigen7 Posted September 12, 2007 Author Share Posted September 12, 2007 ill try this one thx for the help ill post if i cant make it right Link to comment https://forums.phpfreaks.com/topic/68930-solved-helpsaving-generated-web-search-result-by-yahoo-using-linkdomain/#findComment-346598 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.