ExpressYourself
Registered
Мога ли да взема времето за град Казанлък с PHP от sinoptik.bg
Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
appmaster каза:Мисля че синоптика специално си има данните в XML - следователно много лесно може да ги вземеш от него![]()
<?php
$f = file_get_contents("http://www.vremeto.bg/city.php?city=3001");
preg_match('/<span class="temp color[0-9]">(.*)<\/span>/i', $f, $m);
echo $m[1];
ExpressYourself каза:Аз се оправих взех ги, а има ли някъв начин направо да си ги напиша от моя сайт да си ги взема![]()
sorRy каза:Нещо не те разбрах. Ако имаш предвид чрез код да ти ги взима ето как ще стане, обаче от http://www.vremeto.bg че в http://sinoptik.bg не намирам Казанлък
ако въпроста ти е друг извинявам обаче не можах да те разбераКод:<?php $f = file_get_contents("http://www.vremeto.bg/city.php?city=3001"); preg_match('/<span class="temp color[0-9]">(.*)<\/span>/i', $f, $m); echo $m[1];![]()
sorRy каза:ми мое лично мнение е, че http://www.vremeto.bg е по добър аз лично там си гледам всеки ден за Враца и ми се струва вярна прогнозата.
<?php
header('Content-Type: text/html; charset=windows-1251');
$target_url = "http://sinoptik.bg/?lid=100726050";
$connect = file_get_contents($target_url);
$swf = explode("<div id=\"swf\"><embed src=\"i/flash/", $connect);
$swf = explode("\" quality=\"high\" wmode=\"transparent\" width=\"391\" height=\"215\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>", $swf[1]);
$swf = iconv('utf-8','windows-1251',urldecode($swf[0]));
$img = explode("<td id=\"icobgr\" style=\"background: url(i/emotion/1/big/", $connect);
$img = explode(") no-repeat center;\" >", $connect);
$img = iconv('utf-8','windows-1251',urldecode($img[0]));
$city = explode("<td class=\"city\" height=\"39\" nowrap style=\"padding-top:10px;\"><b>", $connect);
$city = explode("</b>", $city[1]);
$city = iconv('utf-8','windows-1251',urldecode($city[0]));
$temp1 = explode("<div id=\"temperature2\" class=\"fill\"><b>", $connect);
$temp1 = explode("</b>", $temp1[1]);
$temp1 = iconv('utf-8','windows-1251',urldecode($temp1[0]));
$temp2 = explode("<div id=\"condition2\" class=\"fill\"><b>", $connect);
$temp2 = explode("</b>", $temp2[1]);
$temp2 = iconv('utf-8','windows-1251',urldecode($temp2[0]));
$uset = explode("<b id=\"feelslike\" class=\"f24\">", $connect);
$uset = explode("</b>", $uset[1]);
$uset = iconv('utf-8','windows-1251',urldecode($uset[0]));
$wind = explode("<b id=\"wind\" class=\"f14\">", $connect);
$wind = explode("</b>", $wind[1]);
$wind = iconv('utf-8','windows-1251',urldecode($wind[0]));
$windtype = explode("<b id=\"windtype\" class=\"f14\">", $connect);
$windtype = explode("</b>", $windtype[1]);
$windtype = iconv('utf-8','windows-1251',urldecode($windtype[0]));
$date = date('d.m.Y');
$utre = date("d.m.Y", mktime(0,0,0,date("m"),date("d")+1,date("Y")));
?>
<b>ВРЕМЕТО в <?=date('H:i')?> на <?=date('d.m.Y')?> г.</b>, данни от метеостанция "<?=$city?>"<br>
<a href="<?=$target_url?>" target="_blank" style="text-decoration:none">
<div style="position:absolute;width:391px;height:215px;margin:auto;"><embed src="http://sinoptik.bg/i/flash/<?=$swf?>" quality="high" wmode="transparent" width="391" height="215" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></div>
<div style="position:absolute; z-index:1; padding-left:20px; padding-top:20px;"><font size="+3" color="white"><b><?=$temp1?></b></font></div>
<div style="position:absolute; z-index:1; padding-left:20px; padding-top:50px;"><font size="+1" color="white"><b><?=$temp2?></b></font></div>
<?
if (date('H:i') > '08:00' || date('H:i') < '18:00') {
echo '<div align="right" style="position:absolute; padding-top:168px; width:381px; height:215px;"><font size="+1" color="gray"><b>Усеща се като:</font><font size="+2" color="gray">'.$uset.'</b></font></div>';
}
if (date('H:i') > '18:00' || date('H:i') < '08:00') {
echo '<div align="right" style="position:absolute; padding-top:168px; width:381px; height:215px;"><font size="+1" color="white"><b>Усеща се като:</font><font size="+2" color="white">'.$uset.'</b></font></div>';
}
?>
<div align="right" style="position:absolute; padding-top:190px; width:381px; height:215px;color:gray;">Вятър:<font size="3px"><b><?=$wind?></b></font> Сила:<font size="3px"><b><?=$windtype?></b></font></div>
</a>
djpatzo каза:http://ulnet.net/#/Weather/ тук вземам времето от синоптика и до сега проблеми съм нямал. Мога направо да ти дам кода, който ползвам, а той е:Код:<?php header('Content-Type: text/html; charset=windows-1251'); $target_url = "http://sinoptik.bg/?lid=100726050"; $connect = file_get_contents($target_url); $swf = explode("<div id="swf"><embed src="i/flash/", $connect); $swf = explode("" quality="high" wmode="transparent" width="391" height="215" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>", $swf[1]); $swf = iconv('utf-8','windows-1251',urldecode($swf[0])); $img = explode("<td id="icobgr" style="background: url(i/emotion/1/big/", $connect); $img = explode(") no-repeat center;" >", $connect); $img = iconv('utf-8','windows-1251',urldecode($img[0])); $city = explode("<td class="city" height="39" nowrap style="padding-top:10px;"><b>", $connect); $city = explode("</b>", $city[1]); $city = iconv('utf-8','windows-1251',urldecode($city[0])); $temp1 = explode("<div id="temperature2" class="fill"><b>", $connect); $temp1 = explode("</b>", $temp1[1]); $temp1 = iconv('utf-8','windows-1251',urldecode($temp1[0])); $temp2 = explode("<div id="condition2" class="fill"><b>", $connect); $temp2 = explode("</b>", $temp2[1]); $temp2 = iconv('utf-8','windows-1251',urldecode($temp2[0])); $uset = explode("<b id="feelslike" class="f24">", $connect); $uset = explode("</b>", $uset[1]); $uset = iconv('utf-8','windows-1251',urldecode($uset[0])); $wind = explode("<b id="wind" class="f14">", $connect); $wind = explode("</b>", $wind[1]); $wind = iconv('utf-8','windows-1251',urldecode($wind[0])); $windtype = explode("<b id="windtype" class="f14">", $connect); $windtype = explode("</b>", $windtype[1]); $windtype = iconv('utf-8','windows-1251',urldecode($windtype[0])); $date = date('d.m.Y'); $utre = date("d.m.Y", mktime(0,0,0,date("m"),date("d")+1,date("Y"))); ?> <b>ВРЕМЕТО в <?=date('H:i')?> на <?=date('d.m.Y')?> г.</b>, данни от метеостанция "<?=$city?>"<br> <a href="<?=$target_url?>" target="_blank" style="text-decoration:none"> <div style="position:absolute;width:391px;height:215px;margin:auto;"><embed src="http://sinoptik.bg/i/flash/<?=$swf?>" quality="high" wmode="transparent" width="391" height="215" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></div> <div style="position:absolute; z-index:1; padding-left:20px; padding-top:20px;"><font size="+3" color="white"><b><?=$temp1?></b></font></div> <div style="position:absolute; z-index:1; padding-left:20px; padding-top:50px;"><font size="+1" color="white"><b><?=$temp2?></b></font></div> <? if (date('H:i') > '08:00' || date('H:i') < '18:00') { echo '<div align="right" style="position:absolute; padding-top:168px; width:381px; height:215px;"><font size="+1" color="gray"><b>Усеща се като:</font><font size="+2" color="gray">'.$uset.'</b></font></div>'; } if (date('H:i') > '18:00' || date('H:i') < '08:00') { echo '<div align="right" style="position:absolute; padding-top:168px; width:381px; height:215px;"><font size="+1" color="white"><b>Усеща се като:</font><font size="+2" color="white">'.$uset.'</b></font></div>'; } ?> <div align="right" style="position:absolute; padding-top:190px; width:381px; height:215px;color:gray;">Вятър:<font size="3px"><b><?=$wind?></b></font> Сила:<font size="3px"><b><?=$windtype?></b></font></div> </a>
Това е кода който аз ползвам. Мога да ти го преработя да ползваш изображенията да ползваш да не е Flash