aditya_sfs Posted January 24, 2007 Share Posted January 24, 2007 Hello guys,I am a PHP newbie and need a bit of help in developing a tool.I need to count the number of backlinks a site has in MSN. For this i search msn for "link:www.domain.com". I use the following code to do this<?php$lines = file('http://search.live.com/results.aspx?q=link%3Adomain.com');echo "Line #73 : " . htmlspecialchars($lines[73]) . "<br />\n";?> Now line 73 is a big complicated HTML string which can be accessed with $lines[73]. Somewhere in the sting, a small part of it is - <h1>link:domain.com</h1><h5>Page 1 of 26,915 results</h5>Now i want to get that number 26,915 out in another variable and also removing out that comma so that i could do arithmetic operations on it.Please help me. I tried to do it for hours but unsuccessful with the preg_matchregardsAditya Quote Link to comment https://forums.phpfreaks.com/topic/35551-small-preg_match-help-needed/ Share on other sites More sharing options...
Jessica Posted January 24, 2007 Share Posted January 24, 2007 Post the code you used with preg_match.The regex should check for page x of x results. Quote Link to comment https://forums.phpfreaks.com/topic/35551-small-preg_match-help-needed/#findComment-168300 Share on other sites More sharing options...
aditya_sfs Posted January 24, 2007 Author Share Posted January 24, 2007 No i am a completely noob in this matter. I just played with it a bit reading tutorials etc thinking that i would be able to do it. preg_match("/^(<h5>Page 1 of )|(results</h5>)$/", "$test", $matches);echo "$matches[2]";Thats what a n00b can write ;D ;D ;D Quote Link to comment https://forums.phpfreaks.com/topic/35551-small-preg_match-help-needed/#findComment-168308 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.