From 9a4c2a8b36839bbfba5be1eb146bca2806121d30 Mon Sep 17 00:00:00 2001 From: AB Date: Mon, 30 Apr 2018 00:42:47 +0300 Subject: [PATCH] Initial --- .gitignore | 3 ++ .vscode/launch.json | 117 ++++++++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 4 ++ __app__.py | 9 ++++ main.py | 36 +++++++++++++ reqs.txt | 5 ++ settings.py | 33 ++++++++++++ 7 files changed, 207 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 __app__.py create mode 100644 main.py create mode 100644 reqs.txt create mode 100644 settings.py diff --git a/.gitignore b/.gitignore index 7bbc71c..8d31a21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# configs +assets/config.json + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a68063e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,117 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "name": "Python: Current File", + "type": "python", + "request": "launch", + "program": "${file}" + }, + { + "name": "Python: Attach", + "type": "python", + "request": "attach", + "localRoot": "${workspaceFolder}", + "remoteRoot": "${workspaceFolder}", + "port": 3000, + "secret": "my_secret", + "host": "localhost" + }, + { + "name": "Python: Terminal (integrated)", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal" + }, + { + "name": "Python: Terminal (external)", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "externalTerminal" + }, + { + "name": "Python: Django", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/manage.py", + "args": [ + "runserver", + "--noreload", + "--nothreading" + ], + "debugOptions": [ + "RedirectOutput", + "Django" + ] + }, + { + "name": "Python: Flask (0.11.x or later)", + "type": "python", + "request": "launch", + "module": "flask", + "env": { + "FLASK_APP": "${workspaceFolder}/app.py" + }, + "args": [ + "run", + "--no-debugger", + "--no-reload" + ] + }, + { + "name": "Python: Module", + "type": "python", + "request": "launch", + "module": "module.name" + }, + { + "name": "Python: Pyramid", + "type": "python", + "request": "launch", + "args": [ + "${workspaceFolder}/development.ini" + ], + "debugOptions": [ + "RedirectOutput", + "Pyramid" + ] + }, + { + "name": "Python: Watson", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/console.py", + "args": [ + "dev", + "runserver", + "--noreload=True" + ] + }, + { + "name": "Python: All debug Options", + "type": "python", + "request": "launch", + "pythonPath": "${config:python.pythonPath}", + "program": "${file}", + "module": "module.name", + "env": { + "VAR1": "1", + "VAR2": "2" + }, + "envFile": "${workspaceFolder}/.env", + "args": [ + "arg1", + "arg2" + ], + "debugOptions": [ + "RedirectOutput" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..27c3a95 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.pythonPath": "C:\\Users\\ab\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe", + "python.formatting.provider": "yapf" +} \ No newline at end of file diff --git a/__app__.py b/__app__.py new file mode 100644 index 0000000..7aecb99 --- /dev/null +++ b/__app__.py @@ -0,0 +1,9 @@ +from main import Main + + +username='4016014' +password='40201' + +app = Main(username, password) + +app.auth() \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..b0ff0c8 --- /dev/null +++ b/main.py @@ -0,0 +1,36 @@ +import requests +import settings +import logging +from bs4 import BeautifulSoup + +logging.basicConfig(level=logging.DEBUG) + + +class Main: + def __init__(self, username, password): + self.password = password + self.username = username + self.SessionId = '' + + def auth(self): + r = requests.get(settings.fesmu_root_url) + for c in r.cookies: + if c.name == 'ASP.NET_SessionId': + self.SessionId = c.value + logging.info('ASP.NET_SessionId for curtain session is %s', + c.value) + + r = requests.post( + settings.fesmu_root_url, + data=settings.merge( + settings.scam_data, + { + 'ctl00$MainContent$TextBox1': self.username, + 'ctl00$MainContent$TextBox2': self.password, + } + ), + cookies={'ASP.NET_SessionId': self.SessionId}) + + r = requests.get(settings.fesmu_root_url + 'startstu.aspx', cookies={'ASP.NET_SessionId': self.SessionId}) + soup = BeautifulSoup(r.text, "html.parser") + print(soup.find(id="ctl00_MainContent_Label1")) diff --git a/reqs.txt b/reqs.txt new file mode 100644 index 0000000..3a27007 --- /dev/null +++ b/reqs.txt @@ -0,0 +1,5 @@ +python3 + +py -m pip install requests + +py -m pip install beautifulsoup4 \ No newline at end of file diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..f101973 --- /dev/null +++ b/settings.py @@ -0,0 +1,33 @@ +fesmu_root_url = 'http://www.fesmu.ru/eport/eport/' + +scam_data = { + 'ctl00$MainContent$UserText': + '', + 'ctl00$MainContent$PassText': + '', + '__EVENTTARGET': + '', + 'ctl00_MainContent_ToolkitScriptManager1_HiddenField': + '', + '__EVENTARGUMENT': + '', + '__VIEWSTATE': + '/wEPDwUKLTQ4NzYwNDEzOQ9kFgJmD2QWAgIDD2QWAgIBD2QWAgIFDw8WAh4EVGV4dAU/0KHQtdC50YfQsNGBINC/0L7Qu9GM0LfQvtCy0LDRgtC10LvQtdC5INC90LAg0L/QvtGA0YLQsNC70LU6IDI3ZGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgQFHWN0bDAwJE1haW5Db250ZW50JEFTUHhCdXR0b24xBR1jdGwwMCRNYWluQ29udGVudCRBU1B4QnV0dG9uMwUdY3RsMDAkTWFpbkNvbnRlbnQkQVNQeEJ1dHRvbjIFHWN0bDAwJE1haW5Db250ZW50JEFTUHhCdXR0b240UKid19jR9/BwYJ38PlfAuTBp+Uzf293yX1YKxRuGOwU=', + '__VIEWSTATEGENERATOR': + '73D4C735', + '__EVENTVALIDATION': + '/wEdAAdNVwQOOnBLF+XCfUz1/WyqUN0eEH6RAZcaSKVdt8S4X7osef1mutGT26WuFCdWwFYhaXIQoXEs7lyT4XozQ4OInWK1mn7aEBNhVaP9v76fJNxRJK/kVxlULg0AsW337/IhsIAW9IW5kv7Tf6wiSWjxg3zGz2OD5sbWFNEoFylrnnGelA7yCE4KHy7DzyQ2uf0=', + 'ctl00$MainContent$ASPxButton2': + '', + 'ctl00$MainContent$TextBox3': + '', + 'ctl00$MainContent$TextBox4': + '', + 'DXScript': + '1_42,1_75,2_27' +} + +def merge(x, y): + z = x.copy() # start with x's keys and values + z.update(y) # modifies z with y's keys and values & returns None + return z \ No newline at end of file