Easy steps: (based on 19 players. If you have more or less, modify the code and the alias commands)
1) Create a new file, copy and paste below code and run it.
#!/usr/bin/php
<?
# ntvspor fm simple viewer by hz muhammed
set_time_limit(0);
$username = "user";
$password = "pass";
$useragent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030430 Mozilla Firebird/0.6";
$sessionid = "";
gogogo();
function gogogo()
{
global $username, $password;
global $sessionid, $useragent;
$postdata = "auth.username=".urlencode($username)."&auth.passwort=".urlencode($password)."&auth.permanent=true";
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, "http://fm.ntvspor.net/app/info.jsp");
curl_setopt($c, CURLOPT_USERAGENT, $useragent);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $postdata);
$res = curl_exec($c);
curl_close($c);
$sessionid = getsessid($res);
details(19);
}
function wdet($str) {
$fp = fopen("data.txt", "a+");
if(!$fp) return;
preg_match("/\<h3\>Profil -(.*)\<\/h3\>/", $str, $mat);
$playername = trim($mat[1]);
$playername = preg_replace("/<img(.*)>/", "*", $playername);
preg_match_all("/\<span class=\"body\"\>[<strong>]*((\d+){1,3},(\d+){1,3})[<\/strong>]*\<\/span\>/", $str, $mat);
$det = $mat[1];
$str = strstr($str, "Toplam");
preg_match_all("/<td\>(\d+)\<\/td\>/", $str, $mat);
$toplam = $mat[1][0];
$out= "$playername;$toplam;$det[0];$det[1];$det[2];$det[3]\n";
fwrite($fp, $out);
echo $out;
fclose($fp);
}
function details($cnt) {
global $username, $password;
global $sessionid, $useragent;
for($i = 1 ; $i <= $cnt ; $i++) {
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, "http://fm.ntvspor.net/app/player-info.jsp?spieler=$i");
curl_setopt($c, CURLOPT_USERAGENT, $useragent);
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_COOKIE, $sessionid);
$res = curl_exec($c);
curl_close($c);
wdet($res);
}
}
function getsessid($body) {
preg_match_all("/Set-Cookie: (.*); path/", $body, $mat);
$s = "";
$gl = "";
$fff = $mat[1];
for($i = 0 ; $i < count($fff) ; $i++) {
$s .= $gl . $fff[$i];
$gl = ";";
}
return $s;
}
?>
2) Create some aliases:
alias fmkeeper='cat data.txt | sort -t '\'';'\'' -k 6 -r | sed '\''s/,/./g'\'' | awk -F'\'';'\'' '\''{printf("%20s : %.2f\n", $1, $6)}'\'''
alias fmdef='cat data.txt | sort -t '\'';'\'' -k 5 -r | sed '\''s/,/./g'\'' | awk -F'\'';'\'' '\''{printf("%20s : %.2f\n", $1, $5)}'\'''
alias fmfwd='cat data.txt | sort -t '\'';'\'' -k 3 -r | sed '\''s/,/./g'\'' | awk -F'\'';'\'' '\''{printf("%20s : %.2f\n", $1, $3)}'\'''
alias fmmid='cat data.txt | sort -t '\'';'\'' -k 4 -r | sed '\''s/,/./g'\'' | awk -F'\'';'\'' '\''{printf("%20s : %.2f\n", $1, $4)}'\'''
alias fmtot='cat data.txt | sort -t '\'';'\'' -k 2 -r | sed '\''s/,/./g'\'' | awk -F'\'';'\'' '\''{printf("%20s : %d\n", $1, $2)}'\'''
alias fmavg='fmtot|awk -F'\'': '\'' '\''{c+=$2} END {print c/19}'\'''
3) Run aliases, e.g fmdef to see the players sorted in the defensive order.