Last active
March 3, 2016 03:33
-
-
Save temoto/efc4cf36fe388b41715b to your computer and use it in GitHub Desktop.
Экспорт балансов Мегафона. Работает с TLSv1 уральского региона (информация актуальна 2016-03-03).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://gist.github.com/temoto/efc4cf36fe388b41715b | |
set -e | |
umask 0077 | |
cookie_path='/tmp/megafon-jar' | |
output_path=~/megafon-account.csv | |
username='EDIT' | |
password='EDIT' | |
url_base='https://EDIT' | |
url_path_init='/sc_cp_apps/login' | |
url_path_login='/sc_cp_apps/loginProcess' | |
url_path_account='/sc_cp_apps/account/export.csv' | |
curl="curl --tlsv1 -fsS --compressed --tr-encoding" | |
curl_cookie="${curl} -b $cookie_path -c $cookie_path" | |
rm -f megafon-jar | |
$curl_cookie "${url_base}${url_path_init}" | |
$curl_cookie -X POST -d "j_username=$username" -d "j_password=$password" "${url_base}${url_path_login}" | |
$curl_cookie -L "${url_base}${url_path_account}" |iconv -f cp1251 -t utf-8 >"$output_path" | |
rm -f megafon-jar | |
echo "Отчет сохранен в файле '$output_path'" | |
echo '---' | |
if [[ -t 1 ]]; then | |
cat $output_path | |
echo '---' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment