This commit is contained in:
AB
2018-04-30 00:42:47 +03:00
parent 6403ee70b8
commit 9a4c2a8b36
7 changed files with 207 additions and 0 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
# configs
assets/config.json
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

117
.vscode/launch.json vendored Normal file
View File

@ -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"
]
}
]
}

4
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"python.pythonPath": "C:\\Users\\ab\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe",
"python.formatting.provider": "yapf"
}

9
__app__.py Normal file
View File

@ -0,0 +1,9 @@
from main import Main
username='4016014'
password='40201'
app = Main(username, password)
app.auth()

36
main.py Normal file
View File

@ -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"))

5
reqs.txt Normal file
View File

@ -0,0 +1,5 @@
python3
py -m pip install requests
py -m pip install beautifulsoup4

33
settings.py Normal file
View File

@ -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