0

I want to get vales from a site which are in tables form

<table class='mytable'>
    <tr><td class='data'>Model</td> <td class='value'>Model 1</td></tr>
    <tr><td class='data'>Price</td> <td class='value'>10000</td></tr>
    <tr><td class='data'>Class</td> <td class='value'>Class new</td></tr>
    ....
    ....
    ....
</table>

I want to get value of each data ie to fetch model as model 1, price as 10000,...

php code i am using to curl

<?php
    $myurl="http://www.example.com/page/";
    $curl = curl_init("$myurl");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($curl, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($curl,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
    curl_setopt($curl, CURLOPT_FAILONERROR, true);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $page = curl_exec($curl);

    if($myurl!='')
        {
        if(!empty($curl))
        { 
            $pokemon_doc = new DOMDocument;
            libxml_use_internal_errors(true);
            $pokemon_doc->loadHTML($page);
            libxml_clear_errors(); //remove errors for yucky html
            $pokemon_xpath = new DOMXPath($pokemon_doc);
            $priceflip =$pokemon_xpath->evaluate('string(//table[@class="mytable"])');

            echo $priceflip;

        }
    }
?>

this is returning whole content as a paragraph

but I want to fetch seperate values regarding to data

Henders
  • 1,195
  • 1
  • 21
  • 27

0 Answers0