Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
53 lines (37 loc) · 1.29 KB

File metadata and controls

53 lines (37 loc) · 1.29 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python
# coding=utf-8
import cookielib
import urllib
import urllib2
def sendRequest(posturl, postData, headers):
postData = urllib.urlencode(postData)
request = urllib2.Request(posturl, postData, headers)
response = urllib2.urlopen(request)
text = response.read()
return text
def sendQuery(url, postData):
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1'}
text = sendRequest(url, postData, headers)
return text
def login(hosturl, username, password):
posturl = hosturl + '/login'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1',
'Referer': posturl}
postData = {
'userName': username,
'password': password
}
text = sendRequest(posturl, postData, headers)
return text
def init():
cj = cookielib.LWPCookieJar()
cookie_support = urllib2.HTTPCookieProcessor(cj)
opener = urllib2.build_opener(cookie_support, urllib2.HTTPHandler)
urllib2.install_opener(opener)
h = urllib2.urlopen(hosturl)
if __name__ == "__main__":
# hosturl = 'http://10.73.37.63:8080'
hosturl = 'http://localhost:8080'
init()
login(hosturl, "zhongsf", "123456")
# 封装所有请求url和参数,
Morty Proxy This is a proxified and sanitized view of the page, visit original site.