hey guys, i'm completely new to cURL - i've never used it before. If i paste the following two lines inside of my sidebar ...
<?php
$objCUrl = curl_init("http://www.domain.com/hptool/weather_v1.php?cid=43X1351&l=en");
curl_exec($objCUrl);
?>
...i get two divs and a table inserted into my page. Is there a method where i can kind of inspect everything that gets loaded with this curl_init function? I just want to get specific stuff on my page inserted and not everything? E.g. i only want to insert the table but not the two divs that get inserted into my page.
I know i could simply hide them with css, but i'm just curious.
Save the result to a string instead of outputting it.
$url = 'http://www.domain.com/hptool/weather_v1.php?cid=43X1351&l=en';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$str = curl_exec($curl);
Now you can pull whatever you need out of $str
and display that.
First place you should go is the documentation for how to use a function/library.
Another common method is to use an output buffer around your curl_exec($objCUrl)
call.
ob_start();
curl_exec($objCUrl);
$str = ob_get_contents();
ob_end_clean();