Hello friends;
We will learn How to Get Data From Another Website Using Php Curl in this article.
We will get a list of movies on mynet in the following example.
<?php
$curl = curl_init(); // starting curl process
curl_setopt($curl,CURLOPT_URL,"http://sinema.mynet.com/vizyondaki-filmler"); // define link
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1); // starting data transfer
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,1); // following link
$sonuc = curl_exec($curl); // and assing to result
preg_match_all('@<div class="vizyonImg">(.*?)</div>@si',$sonuc,$new); /* only select the part we want with preg_match_all. finally we are looping and printing */
preg_match_all('@<ul class="vizyonInfo clr">(.*?)</ul>@si',$sonuc,$info);
$new = $new[0];
$info = $info[0];
echo '<ul>';
for($i=0; $i < count($info);$i++){
echo '<li>';
echo $new[$i].'<br>';
echo $info[$i];
echo '</li>';
}
echo '</ul>';
?>
$curl = curl_init(); // starting curl process
curl_setopt($curl,CURLOPT_URL,"http://sinema.mynet.com/vizyondaki-filmler"); // define link
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1); // starting data transfer
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,1); // following link
$sonuc = curl_exec($curl); // and assing to result
preg_match_all('@<div class="vizyonImg">(.*?)</div>@si',$sonuc,$new); /* only select the part we want with preg_match_all. finally we are looping and printing */
preg_match_all('@<ul class="vizyonInfo clr">(.*?)</ul>@si',$sonuc,$info);
$new = $new[0];
$info = $info[0];
echo '<ul>';
for($i=0; $i < count($info);$i++){
echo '<li>';
echo $new[$i].'<br>';
echo $info[$i];
echo '</li>';
}
echo '</ul>';
?>
That's it. Get Data From Another Website Using Php Curl actually very simple and easy.
If you have any questions, you can ask in the comments section.
I hope it has been helpful.
İlk Yorumu Sen Yap