I want to parse the data obtained by using CURL to get useful information from the result
As guided i am reposting the question in full detail. The aim of code is to retrieve the result from remote server and store it to my database and then display it when required by user from my server's database.
i want to retrieve individual sbjec开发者_开发问答t and marks from the site.
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_POST, true);
curl_setopt($request, CURLOPT_POSTFIELDS, array('rid' => '1kn06cs032','submit' => 'SUBMIT'));
if(!($result = curl_exec($request)))
die('curl_exec failed with error: '.curl_error($request));
curl_close($request);
//echo strip_tags($result,'<tr><b><td>') ;
$s=strip_tags($result,'') ;
//strstr($s,")");
$t=strstr($s,"(PROVISIONAL)");
echo $t;
//$a=explode('Semester:',$t);
//echo $a[0];
//echo $a[1];
?>
Please guide me in this regard i have struck in this as i have tried many alternative bt no luck as i have little knowledge of parsing and basic knowledge of php .
Help will be highly appreciated.
Thanks
This still isn't really enough information. The output that you get back from this Curl
call would be useful.
It may be worth looking into PHP's DomDocument and DomXpath this will allow you to query HTML and XML using Xpath's query language
For example :
$dom = new DomDocument();
$dom->loadHTMLFile(HTML_FROM_CURL_HERE);
$xpath = new DOMXpath();
// Get all divs
$divs = $xpath->query("//div");
// Get the div with the id of 'container' which is direct child of the body element
$container = $xpath->query("/body/div[id='container']");
I hope that gets you started.
Jake
use this method to parse the data
$result = curl_exec($request);
$json_a1=json_decode($result,true);
$json_o1=json_decode($result);
foreach($json_o1->data as $p1)
{
echo $p1->id;
}
精彩评论