-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathservicedesk.py
executable file
·33 lines (29 loc) · 1.91 KB
/
servicedesk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3.4
import requests, re
from bs4 import BeautifulSoup
from passwd import sd_user, sd_pass
def get_parameters_vm(taskid):
loginurl = 'https://servicedesk.phoenixit.ru'
logindata = {'autologin' : '1', 'login' : sd_user, 'password' : sd_pass, 'enter' : 'submit'}
headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0', 'Content-type' : 'application/x-www-form-urlencoded'}
session=requests.session()
login=session.post(loginurl, params=logindata, headers=headers)
url = loginurl + '/Task/View/' + taskid
soup = BeautifulSoup(session.get(url).content, 'html.parser')
d = {}
d.update({'hostname':soup.find('input', id='field1041').get('value')})
d.update({'hdd': soup.find('select', id='field1015').find('option', selected="true").text})
d.update({'cpu': soup.find('select', id='field1017').find('option', selected="true").text})
d.update({'ram': soup.find('select', id='field1014').find('option', selected="true").text})
d.update({'os': soup.find('select', id='field1016').find('option', selected="true").text})
d.update({'exp': re.match( "\d\d.\d\d.20\d\d", soup.find('input', id='field1022').get('value') ).group(0)})
d.update({'foldervm': soup.find('input', id='field1020').get('value')})
d.update({'status': soup.find('select', class_='px200 required').find('option', selected="selected").text})
d.update({'taskname': soup.find('input', id='name').get('value').replace("/","-").replace("&","-").replace("?","-")})
d.update({'practica': soup.find('input', id='field1024').get('value')})
d.update({'block': soup.find('select', id='field1023').find('option', selected="true").text})
d.update({'code': soup.find('input', id='field1020').get('value')})
d.update({'owner': soup.find('ul', class_='users').find('a', class_='nounderline').text})
return d
# for debug
#print ( get_parameters_vm( "26963" ) )