Anonymní profil peter – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil peter – Programujte.comAnonymní profil peter – Programujte.com

 

Příspěvky odeslané z IP adresy 2001:718:2601:26c:ec18:69...–

peter
Inzerce › Hledáme programátorna na vyt…
15. 1. 2016   #207964

čakodůrových kodů
ča-kodů-rových kodů

peter
Offtopic › Televizní program - data
15. 1. 2016   #207959

Jeste mozna jeden tip: http://m.tv.sms.cz/
Z tech ruznych stranek, mozna na to maji plugin v js, ktery to pak parsuje na html.

peter
Offtopic › Televizní program - data
15. 1. 2016   #207958

https://www.google.cz/search?q=televizni+program+csv
* http://tv.seznam.cz/ - nabizi sloupkovy radkovy program (70 stanic)
* http://m.tv.seznam.cz/ - mobilni verze, bude zjednodusena
* http://tvprogram.idnes.cz/ - nabizi strucny vypis (140 stanic)
Vsadim se, ze by stacilo jim napsat a by ti rekli, kde maji xml, pripadne csv verzi.

Zpracovani xml je problem? Proc? 
Vysledek: http://webapp.fpf.slu.cz/…wheather.php

<?php
// UTF8

function att($att,$type=0,$row=0)
{
global $xml;
switch ($type)
  {
  case 1 : return $xml->channel->item->{$att};			//item meteoskop
  case 2 : return $xml->pocasi->predpoved->{$row}->{$att};	//item meteocentrum
  case 3 : return $xml->channel->item->{$row}->{$att};		//item wunderground
  default: return $xml->channel->{$att};			//head meteoskop / wunderground
  }
}

function img($name,$width=35,$title='',$str='')
{
$out  = $title;
$name = $name * 1;
if ($name>1 && $name<19)
	{
	$name  = $name.'.png';
	$url   = 'img-mc/'.$name;
	$width = $width==60 || $width==35 ? $width : 35;
	$out   = sprintf('<img src="%s" alt="%s" width="%s" title="%s"><!--%s-->',$url,$name,$width,$title,$str);
	}
return $out;
}

function condToImg($str,$width=35)
{
global $cond_images, $cond_image_titles;
$id    = isset($cond_images[$str])      ? $cond_images[$str]      : $str;
$title = isset($cond_image_titles[$id]) ? $cond_image_titles[$id] : $str;
//echo '(',$str.'-'.$id.')';
return img($id,$width,$title,$str);
}

$cond_images = array(
'Clear' => 2,
'Scattered Clouds' => 3,
'Overcast' => 4,
'Cloudy' => 5,
'Mostly Cloudy' => 5,
'Partly Cloudy' => 6,
'Patches Fog' => 7,
'Patches of Fog' => 7,
'Light Rain' => 8,
'Rain' => 9,
'Chance of Rain' => 10,
'T-storms' => 11,
'Thunderstorm' => 11,
'Thunderstorms and Rain' => 11,
'Light Thunderstorm' => 12,
'Chance of T-storms' => 12,
'Chance of a Thunderstorm' => 12,
'Light Snow' => 13,
'Snow' => 14,
'Heavy Snow' => 14,
'Fog' => 7,
'Shallow Fog' => 7,
'Light Snow Mist' => 14,
'Light Showers Rain' => 8,
'Light Drizzle Mist' => 7,
'Light Drizzle' => 8,
'Light Showers Rain Snow Mist' =>17,
'Light Rain Mist' => 8,
'Heavy Showers Rain' => 9,
'Haze' => 7,
'Mist' => 7,
'Chance of Snow' => 15
);
$cond_image_titles = array(
1  => "N/A Data nejsou k dispozici",
2  => "jasno",
3  => "polojasno",
4  => "oblaÄŤno",
5  => "zataĹľeno",
6  => "zataĹľeno nĂ­zkou oblaÄŤnostĂ­",
7  => "mlha",
8  => "slabĂ˝ dĂcšť",
9  => "dĂcšť",
10 => "dešťovĂc pĹteháĹ_ky",
11 => "bouĹtky",
12 => "obÄŤasnĂc bouĹtky",
13 => "slabĂc snÄ>ĹľenĂ­",
14 => "snÄ>ĹľenĂ­",
15 => "snÄ>hovĂc pĹteháĹ_ky",
16 => "dĂcšť se snÄ>hem",
17 => "dĂcšť se snÄ>hem - pĹteháĹ_ky",
18 => "kroupy"
);

//$url  = "http://rss.wunderground.com/auto/rss_full/global/stations/12540.xml?units=metric";	// Ratibor, PL
$url  = "http://rss.wunderground.com/auto/rss_full/global/stations/11782.xml?units=metric";	// Ostrava, CZ
$data = file_get_contents($url);	//$data  = iconv("iso-8859-2", "UTF-8", $data );
$xml  = simplexml_load_string($data);

$tpl_today = '
<table class="f1">
  <caption>%s</caption>
  <tr>
    <td width="35">%s</td>
    <td><div class="temp">%s</div></td>
  </tr>
  <tr>
    <td colspan="2">
      <div class="wind">VĂ­tr: %s</div>
      <div class="hum">Vlhkost: %s</div>
    </td>
  </tr>
</table>';
$loc  = "Opava";
$desc = att('description',3,0);
$desc = trim(strip_tags(str_replace('<![CDATA[','',str_replace(']]>','',$desc))));
//echo htmlspecialchars($desc);
$desc = explode(" | ",$desc);
$winddirs = array(
'Variable' => 'promÄ>nlivĂ˝',
'South' => 'J',
'North' => 'S',
'East'  => 'V',
'West'  => 'Z',
'S' => 'J',
'N' => 'S',
'E' => 'V',
'W' => 'Z'
);
$daynames = array(
'?',
'PondelĂ­',
'ĂšterĂ˝',
'StĹteda',
'ÄŚtvrtek',
'Pátek',
'Sobota',
'NedÄ>le'
);
$val   = array(
	 'cond'    => trim(str_replace('Conditions: '    ,'',$desc[3])),
	 'temp'    => trim(str_replace('Temperature: '   ,'',$desc[0])),
	 'winddir' => trim(str_replace(array_keys($winddirs),$winddirs,preg_replace('/^.*\:/','',$desc[4]))),
	 'windspd' => trim(str_replace('km/h',' km/h',str_replace('Wind Speed: ','',$desc[5]))),
	 'hum'     => trim(str_replace('Humidity: '      ,'',$desc[1])),
	 'date'    => preg_replace('/\D/','',att('guid',3,0)) * 1
	);
$loc  .= '<br/>'.str_replace(array_keys($daynames),$daynames,date("N",$val['date'])). ' ' .date("j.n.Y G:i",$val['date']);
$link1 = sprintf('<div><small>Zdroj: <a href="%s">%s</a></small></div>',att('link',3,0),preg_replace('/RSS.*$/','',att('description')));
$tab1  = sprintf($tpl_today, $loc, condToImg($val['cond'],60),$val['temp'],$val['winddir'].', '.$val['windspd'],$val['hum']);

$tpl_row = '
  <tr>
    <td>%s</td>
    <td><div class="temp">%s</div></td>
    <td>&nbsp;%s</td>
  </tr>';
$desc = att('description',3,1);
$tab2 = '';
for ($i=0;$i<3;$i++)
  {
  $j = $i*2+1;
  $desc_day   = att('description',3,$j);
  $desc_day   = explode(". ",trim($desc_day));
  $desc_night = att('description',3,$j+1);
  $desc_night = explode(". ",trim($desc_night));
  $val   = array(
	 'cond'    => trim($desc_day[0]),
	 'temp'    => trim(preg_replace('/[\.\s]/','',preg_replace('/^.*\:/','',$desc_day[1]))) .' / '.trim(preg_replace('/[\.\s]/','',preg_replace('/^.*\:/','',$desc_night[1]))),
//	 'date'    => strtotime(trim(att('pubDate',3,$j)))
	 'date'    => time() - preg_replace('/^\d*|\D*$/','',att('guid',3,$j))*86400
	);
  $tab2 .= sprintf($tpl_row, condToImg($val['cond'],35),$val['temp'],date("j.n.",$val['date']));
  }
$link2 = sprintf('<div><small>Zdroj: <a href="%s">%s</a></small></div>','http://www.meteocentrum.cz','PoÄŤasĂ­ Meteocentrum');


$html  = '<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>PoÄŤasĂ­</title>
<style type="text/css">
html, body {margin:0;padding:0;}
.f1, .f2 {border-collapse:collapse; border-spacing:0; min-width:170px;}
.f1 caption {font-weight:bold;text-align:left;}
.f1 caption:first-letter {text-transform:uppercase;}
.f2 {color:#666;}
.f1 .temp {font-size:125%;}
.f2 .temp {font-size:85%;}
small, small a {color:#888;}
</style>
</head>
<body>
'.$tab1.'
<table class="f2">
'.$tab2.'
</table>
'.$link1.'
'.$link2.'
</body>
</html>
';
header('content-type: text/html; charset: utf-8');
echo $html;


/*
// http://www.meteoskop.cz/pocasi/praha-1 <- http://meteocentrum.cz/
// http://www.google.com/ig/api?…
// http://www.exorithm.com/…her_forecast
// google 2: igoogle.wunderground.com/cgi-bin/findweather/getForecast?query=49.940659,17.894798
// google 2: http://www.wunderground.com/…/hdfForecast?…

//http://www.wunderground.com/weather/api/d/docs?d=resources/icon-sets
$img_wunder = array(		//http://icons.wxug.com/i/c/h/ ; NAME.gif ; nt_NAME.gif
chanceflurries			//NAME
chancerain
chancesleet
chancesleet
chancesnow
chancetstorms
chancetstorms
clear
cloudy
flurries
fog
hazy
mostlycloudy
mostlysunny
partlycloudy
partlysunny
sleet
rain
sleet
snow
sunny
tstorms
tstorms
tstorms
cloudy
partlycloudy


<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Raciborz,  Weather from Weather Underground
    </title>	
    <link>http://www.wunderground.com/
    </link>	
    <description>Weather Underground RSS Feed for Raciborz,  PL
    </description>	
    <language>EN
    </language>        
    <generator>WU-RSS
    </generator>        
    <webMaster>support@wunderground.com (Wunderground Support)
    </webMaster>	
    <category>weather
    </category>        
    <image>                
      <url>http://icons.wunderground.com/graphics/smash/wunderTransparent.gif
      </url>                
      <link>http://www.wunderground.com/
      </link>                
      <title>Raciborz,  Weather from Weather Underground
      </title>          
    </image>        
    <pubDate>Wed, 19 Sep 2012 10:49:00 CEST
    </pubDate>        
    <lastBuildDate>Wed, 19 Sep 2012 10:49:00 CEST
    </lastBuildDate>	
    <ttl>5
    </ttl>
    <item>
      <guid isPermaLink="false">1348044557
      </guid>
      <title>Current Conditions : 12.5C, Light Rain - 10:49 AM CEST Sep. 19
      </title>
      <link>http://www.wunderground.com/global/stations/12540.html
      </link>	
      <description>
        <![CDATA[Temperature: 12.5&deg;C | Humidity: 93% | Pressure: 1012hPa (Rising) | Conditions: Light Rain | Wind Direction: NW | Wind Speed: 20.9km/h<img src="http://server.as5000.com/AS5000/adserver/image?ID=WUND-00071&C=0" width="0" height="0" border="0"/>]]> 	
      </description>        
      <pubDate>Wed, 19 Sep 2012 10:49:00 CEST
      </pubDate>
    </item>
    <item>
      <title>Forecast for Tuesday as of Sep. 18 2:00 PM CEST
      </title>
      <link>http://www.wunderground.com/global/stations/12540.html
      </link>      
      <description>	Overcast. High:21 &amp;deg; C.       
      </description>      
      <pubDate>Tue, 18 Sep 2012 12:00:00 GMT
      </pubDate>      
      <guid isPermaLink="false">1347969600-1-day
      </guid>
    </item>
    <item>
      <title>Forecast for Tuesday Night as of Sep. 18 2:00 PM CEST
      </title>
      <link>http://www.wunderground.com/global/stations/12540.html
      </link>           
      <description>	Overcast. Low:14 &amp;deg; C.       
      </description>      
      <pubDate>Tue, 18 Sep 2012 12:00:00 GMT
      </pubDate>      
      <guid isPermaLink="false">1347969600-1-night
      </guid>
    </item>
    <item>
      <title>Forecast for Wednesday as of Sep. 18 2:00 PM CEST
      </title>
      <link>http://www.wunderground.com/global/stations/12540.html
      </link>      
      <description>	Scattered Clouds. High:23 &amp;deg; C.       
      </description>      
      <pubDate>Tue, 18 Sep 2012 12:00:00 GMT
      </pubDate>      
      <guid isPermaLink="false">1348056000-2-day
      </guid>
    </item>
    <item>
      <title>Forecast for Wednesday Night as of Sep. 18 2:00 PM CEST
      </title>
      <link>http://www.wunderground.com/global/stations/12540.html
      </link>           
      <description>	Scattered Clouds. Low:13 &amp;deg; C.       
      </description>      
      <pubDate>Tue, 18 Sep 2012 12:00:00 GMT
      </pubDate>      
      <guid isPermaLink="false">1348056000-2-night
      </guid>
    </item>
    <item>
      <title>Forecast for Thursday as of Sep. 18 2:00 PM CEST
      </title>
      <link>http://www.wunderground.com/global/stations/12540.html
      </link>      
      <description>	Chance of Rain. High:17 &amp;deg; C.       
      </description>      
      <pubDate>Tue, 18 Sep 2012 12:00:00 GMT
      </pubDate>      
      <guid isPermaLink="false">1348142400-3-day
      </guid>
    </item>
    <item>
      <title>Forecast for Thursday Night as of Sep. 18 2:00 PM CEST
      </title>
      <link>http://www.wunderground.com/global/stations/12540.html
      </link>           
      <description>	Rain. Low:9 &amp;deg; C.       
      </description>      
      <pubDate>Tue, 18 Sep 2012 12:00:00 GMT
      </pubDate>      
      <guid isPermaLink="false">1348142400-3-night
      </guid>
    </item>
  </channel>
</rss>

meteocentrum
<?xml version='1.0' encoding="utf-8"?>

<rss version="2.0"> 
  <pocasi> 
     <predpoved>
      <den>ÄŚtvrtek</den> 
      <datum>20. 9.</datum> 
      <teplota>15°C /5°C</teplota> 
      <stav>DešťovĂc pĹteháĹ_ky</stav> 
      <obrazek>10</obrazek> 
     </predpoved>      <predpoved>
      <den>Pátek</den> 
      <datum>21. 9.</datum> 
      <teplota>16°C /1°C</teplota> 
      <stav>Polojasno</stav> 
      <obrazek>3</obrazek> 
     </predpoved> 
     <predpoved>
      <den>Sobota</den> 
      <datum>22. 9.</datum> 
      <teplota>14°C /5°C</teplota> 
      <stav>slabĂ˝ dĂcšť</stav> 
      <obrazek>8</obrazek> 
     </predpoved> 
  </pocasi> 
</rss>
*/

/*
$types = array(
1  => "N/A Data nejsou k dispozici",
2  => "jasno",
3  => "polojasno",
4  => "oblaÄŤno",
5  => "zataĹľeno",
6  => "zataĹľeno nĂ­zkou oblaÄŤnostĂ­",
7  => "mlha",
8  => "slabĂ˝ dĂc??",
9  => "dĂc??",
10 => "de??ovĂc pĹteháĹ_ky",
11 => "bouĹtky",
12 => "obÄŤasnĂc bouĹtky",
13 => "slabĂc snÄ>?enĂ­",
14 => "snÄ>?enĂ­",
15 => "snÄ>hovĂc pĹteháĹ_ky",
16 => "dĂc?? se snÄ>hem",
17 => "dĂc?? se snÄ>hem - pĹteháĹ_ky",
18 => "kroupy"
);
$images = array(
1  => "",
2  => "sun",
3  => "partly_cloudy",
4  => "cloudy",
5  => "cloudy",
6  => "cloudy",
7  => "mlha",
8  => "light_rain",
9  => "light_rain",
10 => "light_rain",
11 => "tstorms",
12 => "tstorms",
13 => "light_snow",
14 => "light_snow",
15 => "light_snow",
16 => "light_snow",
17 => "light_snow",
18 => "kroupy"
);
$key = array_search($name, $types);


  case 2 : return $xml->pocasi->predpoved->{$row}->{$att};	//meteocentrum predpoved item
*/
?>
peter
Offtopic › Co se myslí základy programo…
15. 1. 2016   #207957

Zaklady se mysli, ze umis udelat jednoduchy program podle pozadavku. Aby mel treba dve policka od uzivatele a do tretiho policka vypsal soucet. A pak taky vytvareni funkci, prace s cykly.
A vse ostatni aby sis umel dohledat, treba tu praci se soubory.

Dobre je zeptat se primo ve firme, jake o tom maji oni predstavy. Nevim o zadne strance, kde je napsano, ze zaklad jazyka XYZ je ... ABC je...

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032024 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý