Jump to content

Recommended Posts

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)

Link to comment
https://forums.phpfreaks.com/topic/75031-curl-output-manipulation/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.