Possible Duplicate:
How to parse and process HTML with PHP?
i'm building my website with presentations off different products, and i face a few problems using curl basically what i need to do is to get some portions of html from different websites and display on my website ex: title, model, description, user reviews etc.... i managed to accomplish some of the code but when changing the source url stop working... even the source is the same my code:
$url = "http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=2819129&CatId=4938";
//$url = "http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=1808177&csid=_61"; //this one is not working....
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
$source = curl_exec ($ch);
$start_description1 = "</tr>
</tbody>
</table>
<p>";
$end_description1 = "</div>
</div>
<div id=\"Videos\" style=\"display:inline;\">";
$description1_start_pos = strpos($source, $start_description1) + strlen($start_description1);
$description1_end_pos = strpos($source, $end_description1) - $description1_start_pos;
$description1 = substr($source, $description1_start_pos, $description1_end_pos);
echo $description1;
it works perfect but if i change the url it won't work... the problem is the start_description html code... on other pages the html code differs...
instead of:
</tr>
</tbody>
</table>
<p>
new page have:
</tr>
</tbody>
</table>
<p>
or:
</tr>
</tbody>
</table>
<p>
how can i avoid this error? or what to do to avoid cUrl errors, and retrieve the content i want ?
thank you!