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
|
import
socks
import
httplib2
body
=
[
(
'tbUserName'
,
'xxx'
),
(
'tbPassword'
,
'xxx'
),
]
headers
=
{
'Content-type'
:
'application/x-www-form-urlencoded'
,
'User-Agent'
:
'Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17'
}
#proxy = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, 'http://xxx.xxx.com', 8080)
http
=
httplib2.Http(
# proxy_info = proxy
)
response, content
=
http.request(url,
'GET'
, headers
=
headers,
#connection_type='http',
)
# set cookie
headers
=
{
'Cookie'
: response[
'set-cookie'
]}
response, content
=
http.request(
url,
'POST'
, headers
=
headers, body
=
urllib.urlencode(body)
)
print
type
(content)
try
:
content
=
unicode
(content)
self
.view.setHtml(content)
except
:
return
return
|