-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththePythonChallenge 13.py
46 lines (34 loc) · 1.36 KB
/
thePythonChallenge 13.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
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
"""
différents essais pour répondre au challenge:
http://www.pythonchallenge.com/pc/return/disproportional.html
http://www.pythonchallenge.com/pc/phonebook.php
"""
#call him
#phone that evil
import xmlrpclib
################################################
## cett partie ci n'est nécessaire que pour passer le proxy
import urllib2
class ProxyTransport(xmlrpclib.Transport):
def request(self, host, handler, request_body, verbose):
self.verbose = verbose
url = 'http://' + host + handler
if self.verbose: "ProxyTransport URL: [%s]" % url
request = urllib2.Request(url)
request.add_data(request_body)
request.add_header("User-Agent", self.user_agent)
request.add_header("Content-Type", "text/xml")
proxy_handler = urllib2.ProxyHandler({"http":"proxy.priv.atos.fr:3128"})
opener = urllib2.build_opener(proxy_handler)
f = opener.open(request)
return(self.parse_response(f))
p = ProxyTransport()
###################################################
print u"debut du programme"
proxy = xmlrpclib.Server("http://www.pythonchallenge.com/pc/phonebook.php", transport=p)
#version sans proxy:
#proxy = xmlrpclib.Server("http://www.pythonchallenge.com/pc/phonebook.php")
print proxy.phone("Bert") # => 555-ITALY
print proxy.phone("Leopold")
print "fin du prg."