Get content from another site with Curl and PHP


<?php
function get_string_between($string, $start, $end)
{
$string = ” “.$string;
$ini = strpos($string,$start);
if ($ini == 0)
return “”;
$ini += strlen($start);
$len = strpos($string,$end,$ini) – $ini;
return substr($string,$ini,$len);
}
//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Set the URL
curl_setopt($ch, CURLOPT_URL,”http://www.dsebd.org/&#8221;);
//Execute the fetch
$data = curl_exec($ch);

echo $da=get_string_between($data,’imgs/topdown.gif”>’,’imgs/topdown.gif’);
//Close the connection
curl_close($ch);

?>

8 Replies to “Get content from another site with Curl and PHP”

  1. Excellent piece. I was checking continuously this blog and I am quite impressed! Very useful information specifically the last part. I care for such info a lot. I was looking for this particular info for a very long time. Thank you and best of luck.

  2. Excellent post. I was checking constantly this blog and I am quite impressed! Extremely useful info specifically the last part. I care for such info a lot. I was seeking this certain info for a long time. Thank you and good luck.

  3. Excellent article.I love it.How can i fetch data from 2 or more websites at a time by passing parameters to query strings and show that data in my site.Thanks in advance.

Leave a reply to hoai Cancel reply