ايها الاخوة اليكم سكريبت جالب مواقع بسيط بلغة بي اتش بي
اشتغل معي بس مو بالشكل اللازم
الفكرة حلوة انك تحدد الصفحة اللي بدك ياها و لنقل صفحة الطقس في ياهوو و تحددله كود html اللي بدك يجبلك ياه محدث عن طريق تحديد بداية و نهاية الكود
و الباقي عليه
جربوه و بتمنى من الاخوة اللي عندهم سكريبتات فعالة بتعمل نفس العمل ما تبخل علينا فيها
<?
$url = "http://www.examplesite.com/"; // Trailing slash when not using filename
$file = "cache.html"; // file to write to. remember to chmod 777 to not get errors
$unique_start = "<unique HTML tag or text>"; // Where to begin to grab
$unique_end = "<ending marker point>"; // Where to end the grab
$cache_tolerance = 1200; // How many seconds old the cache file can get
//-----------------------------------------------------------
function update_content(&$content) { // use this to modify the HTML tags etc
$content = str_replace('change from','change into',$content);
// use any replacement routines in here.
}
//-----------------------------------------------------------
function write_cache($filename) { // outputs the cached file
// echo 'writing from cache<br>';
$contents = implode("",@file( $filename ) );
update_content ($contents);
echo $contents;
}
//-----------------------------------------------------------
function check_domain($target) { // tests if domain is accessible by opening a socket to it
$fetch_domain = parse_url($target);
$fetch_domain = $fetch_domain[host];
$socket_handle = fsockopen("$fetch_domain", 80, $error_nr, $error_txt,30);
if(!$socket_handle)
{
echo $target . ' could not be reached.<br>';
return "false";
}
return "true";
} // function check_domain
//-------------------------------------------------------------
function update_cache($url,$unique_start,$unique_end,$file) {
// echo 'updating cache<br>';
if (check_domain($url)=='true') { // only update if we find the domain
$handle = fopen ("$url", "rb");
$fd = "";
do {
$data = fread($handle, 8192);
if (strlen($data) == 0) {
break;
}
$fd .= $data;
} while(true);
fclose ($handle);
if ($fd)
{
$start= strpos($fd, "$unique_start");
/* echo "start found at " . $start . "<br>"; */
$finish= strpos($fd, "$unique_end");
/* echo "finish found at " . $finish . "<br>"; */
$length= $finish-$start;
$code=Substr($fd, $start, $length);
}
// output to cache file
$tmpfile = fopen($file,"w+");
$fp = fwrite($tmpfile,$code);
fclose($tmpfile);
flush ();
}
}
//--------------Main section starts here-------------------------------
ini_set('max_execution_time', '0');
flush ();
// check how old the cache file is
if (file_exists($file)) {
clearstatcache(); // filemtime info gets cached so we must ensure that the cache is empty
$time_difference = time() - filemtime($file);
// echo "$file was last modified: " . date ("F d Y H:i:s.", filemtime($file)) . "( " . $time_difference . " seconds ago) <br>" . "The cache is set to update every " . $cache_tolerance . " seconds.<br>";
} else {
$time_difference = $cache_tolerance; // force update
}
if ($time_difference >= $cache_tolerance){ // update the cache if need be
update_cache($url,$unique_start,$unique_end,$file);
}
write_cache($file); // we always only output from cache
?>