jigen7 Posted February 5, 2008 Share Posted February 5, 2008 hi I'm having trouble with this one what i want to do here is that i want to know if a webapge contains the specific string that i've inputted so i do this like this function search_call($url,$search_criteria){ $size = 0; $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // grab URL, and return output $output = curl_exec($ch); // close curl resource, and free up system resources curl_close($ch); echo $output; if (eregi($search_criteria, $output)) { $size = 1; } the problem here is that sometimes it returns that the string is not found. but when i went to the actual site and use the ctrl+f i'll see that it actually contains the actual string.. anyone have better idea doing this?? thx Link to comment https://forums.phpfreaks.com/topic/89470-help-search-a-string-inside-a-curl-variable/ Share on other sites More sharing options...
CerealBH Posted February 5, 2008 Share Posted February 5, 2008 $beg_pos = strpos($this->pageSource,"$before"); $end_pos = strpos($this->pageSource, "$after", $beg_pos); $this->pageSource = substr($this->pageSource, $beg_pos, $end_pos - $beg_pos); Link to comment https://forums.phpfreaks.com/topic/89470-help-search-a-string-inside-a-curl-variable/#findComment-458208 Share on other sites More sharing options...
CerealBH Posted February 5, 2008 Share Posted February 5, 2008 you could also use perl regex preg_match("<img border=\"0\" alt=\"\" src=\"(.*)\" />", $this->pageSource, $var); (.*) being the information your getting http://www.troubleshooters.com/codecorn/littperl/perlreg.htm Link to comment https://forums.phpfreaks.com/topic/89470-help-search-a-string-inside-a-curl-variable/#findComment-458209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.