supermerc Posted June 21, 2009 Share Posted June 21, 2009 Hey, im using curl to get a page and I would like to use preg_match_all to find links that start with something. for example the links look something like this: http://quiver.outwar.com/joinraid.php?raidid=379141&h=abc0bbf0b2e4acfec4b6dc7a3a05557b but the raidid changes every time so i need to grab all the links that start with http://quiver.outwar.com/joinraid.php?raidid= so I can get the raid id from each. can anyone help me with the regex? Quote Link to comment Share on other sites More sharing options...
.josh Posted June 21, 2009 Share Posted June 21, 2009 preg_match_all('~<a[^>]*href\s?=\s?["\']http://quiver.outwar.com/joinraid.php\?raidid=([^"\']*)"~i',$content,$matches); Quote Link to comment Share on other sites More sharing options...
supermerc Posted June 21, 2009 Author Share Posted June 21, 2009 I added print_r($matches); to test it and I get Array ( [0] => Array ( ) [1] => Array ( ) ) and i know for a fact there is atleast one result Quote Link to comment Share on other sites More sharing options...
.josh Posted June 21, 2009 Share Posted June 21, 2009 so in my example, I used $content to represent the page you are cURLing. Are you using the right variable there? If so, did you echo it out to make sure you're actually getting the content? If so, post an example of the link (and some of the content surrounding it) from what you what you retrieved from your cURL. Quote Link to comment Share on other sites More sharing options...
supermerc Posted June 21, 2009 Author Share Posted June 21, 2009 http://pulse.comxa.com/raid/get_raid.php Chancellor Fangore is the link i want to get, this is the code: $data = $result1; echo $data; preg_match_all('~<a[^>]*href\s?=\s?["\']http://quiver.outwar.com/joinraid.php\?raidid=([^"\']*)"~i',$data,$matches); print_r($matches); Quote Link to comment Share on other sites More sharing options...
.josh Posted June 21, 2009 Share Posted June 21, 2009 Okay so you posted it as if it were an absolute link. Well looking at the source they have it as a relative link. So what are you going to do to modify that regex? Quote Link to comment 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.