Exemplo n.º 1
0
def ch17():
    auth_handler = request.HTTPBasicAuthHandler()
    auth_handler.add_password('inflate', 'www.pythonchallenge.com', 'huge',
                              'file')
    jar = cookiejar.CookieJar()
    cookie_handler = request.HTTPCookieProcessor(jar)
    opener = request.build_opener(auth_handler, cookie_handler)
    opener.open('http://www.pythonchallenge.com/pc/def/linkedlist.php')
    hint = list(jar)[0].value
    print('hint:', hint)
    nid = '12345'
    cookies = ''
    while nid:
        url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing=%s' % nid
        r = opener.open(url)
        text = r.read().decode()
        s = re.search(r'and the next busynothing is ([0-9]+)', text)
        if len(list(jar)) > 0:
            cookies += list(jar)[0].value
        if not s:
            nid = None
            print('final:', text)
        else:
            nid = s.groups()[0]
    print(cookies)
    bm = request.unquote_to_bytes(cookies.replace('+', ' '))
    message = bz2.decompress(bm)
    print(message)
    phonebook = xmlrpc.client.ServerProxy(
        'http://www.pythonchallenge.com/pc/phonebook.php')
    phonebook.phone('Leopold')
    list(jar)[0].value = 'the flowers are on their way'
    print(
        opener.open(
            'http://www.pythonchallenge.com/pc/stuff/violin.php').read())
    return 'balloons'
Exemplo n.º 2
0
def _decode_path(fragment):
    if six.PY2:
        return unquote(fragment).decode('utf8')

    return unquote_to_bytes(fragment).decode('utf8')
Exemplo n.º 3
0
Arquivo: http.py Projeto: plq/spyne
def _decode_path(fragment):
    if six.PY2:
        return unquote(fragment).decode('utf8')

    return unquote_to_bytes(fragment).decode('utf8')