jbradley04 Posted April 19, 2012 Share Posted April 19, 2012 Hello, I am trying to crawl a website and get all the domain names listed on the site to output into my php script. I am using the following code.... The main area is the preg match area, since I know nothing about it, nor do I understand it a little bit! $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://link I am getting data from.com); curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result=curl_exec ($ch); curl_close ($ch); // Search The Results From The Starting Site if( $result ) { // LOOKING FOR ANYTHING.COM all .com's preg_match_all( "(.*)\.com", $result, $output, PREG_SET_ORDER ); foreach( $output as $item ) { // ALL LINKS DISPLAY HERE print_r($item); } } Any help would be greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/261216-need-help-with-preg-match/ Share on other sites More sharing options...
teynon Posted April 19, 2012 Share Posted April 19, 2012 You need a ... I cant think of the word... delimiter.... preg_match ("@(.*)\.com@" It can be any character so long as you dont use it in the expression. Link to comment https://forums.phpfreaks.com/topic/261216-need-help-with-preg-match/#findComment-1338634 Share on other sites More sharing options...
jbradley04 Posted April 19, 2012 Author Share Posted April 19, 2012 I'm not sure I understand. I tried what you wrote and that didnt work. Thanks for your help Link to comment https://forums.phpfreaks.com/topic/261216-need-help-with-preg-match/#findComment-1338635 Share on other sites More sharing options...
QuickOldCar Posted April 19, 2012 Share Posted April 19, 2012 Just as Teynon said, need a delimiter, http://php.net/manual/en/regexp.reference.delimiters.php preg_match_all( "/(.*)\.com/", $result, $output, PREG_SET_ORDER ); preg_match_all( "@(.*)\.com@", $result, $output, PREG_SET_ORDER ); preg_match_all( "~(.*)\.com~", $result, $output, PREG_SET_ORDER ); Link to comment https://forums.phpfreaks.com/topic/261216-need-help-with-preg-match/#findComment-1338679 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.