Skip to content

Instantly share code, notes, and snippets.

@mgng
Created March 18, 2011 08:35
Show Gist options
  • Save mgng/875777 to your computer and use it in GitHub Desktop.
Save mgng/875777 to your computer and use it in GitHub Desktop.
<?php
set_time_limit(60);
// http://code.google.com/p/php-excel-reader/
// require_once 'excel_reader2.php';
class Toden
{
private static $_pref_list = array(
'tochigi',
'ibaraki',
'gunma',
'chiba',
'kanagawa',
'tokyo',
'saitama',
'yamanashi',
'numazu',
);
private static $_xls_dir = './xls/';
private static $_csv_dir = './csv/';
public static function saveXlsFile() {
foreach ( self::$_pref_list as $pref ) {
$url = "http://www.tepco.co.jp/images/{$pref}.xls";
$src = @file_get_contents( $url );
if ($src !== false) {
$saved = @file_put_contents( self::$_xls_dir . "{$pref}.xls", $src );
if ( $saved !== false ) {
echo "saved : {$url}\n";
} else {
echo "saved error : {$url}\n";
}
} else {
echo "get error : {$url}\n";
}
}
return true;
}
}
Toden::saveXlsFile();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment