rhock_95 Posted October 27, 2007 Share Posted October 27, 2007 can someone direct me to a source or explain how to get specific content from a page returned from a curl script?...i.e. if the page submits a word (via curl ) to a dictionary site...how can I get get just the requested content in the output display? do I have to strip everything or is is there a way to just grab the targeted content without retriving and stripping the rest of the page (images, text etc etc) Quote Link to comment https://forums.phpfreaks.com/topic/75031-curl-output-manipulation/ Share on other sites More sharing options...
GingerRobot Posted October 27, 2007 Share Posted October 27, 2007 You'll need to set the curl option RETURNTRANSFER to 1 to get the contents in a string. e.g: <?php $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,'your website'); curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); //other curl options $result = curl_exec($ch); You'll then need to use some regular expressions on the returned string, $result, to find the data you need. Theres a subforum on this site for regular expressions, or try looking in the manual: preg_match() On a side note, some dictionary sites do offer an API, which would possibly be an easier way to go. A quick google shows that urbandictionary.com does, but take a look for the one you want. Quote Link to comment https://forums.phpfreaks.com/topic/75031-curl-output-manipulation/#findComment-379480 Share on other sites More sharing options...
rhock_95 Posted October 27, 2007 Author Share Posted October 27, 2007 ok thanks for the reply... not being a php coder pre se'...can you tell me how to use preg_match() to remove unwanted content from the "$result" string ? Quote Link to comment https://forums.phpfreaks.com/topic/75031-curl-output-manipulation/#findComment-379494 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.