Найти - Пользователи
Полная версия: convert get method
Начало » Web » convert get method
1
despair4
def get_param(path):
    path=path.split("?",1)
    print len(path)
    if len(path)<2: return None
    param=path[1].split("&")
    d={}
    for i in param:
        t=i.split("=",1)
        if len(t)<2: return None
        d[t[0]]=html.fromstring(t[1]).text
        print t[0],t[1]
    return d 

выдергиваю параметры из
127.0.0.1 - - “GET /pilot?user=%3F+%3F+&txtName=123+124 HTTP/1.1” 200 -

получается :
{'user': ‘%3F+%3F+’, ‘txtName’: ‘123+124’}

каким модулем можно автоматически поменять + на пробелы и %ХХ на ? или что там они означают?

зы тренируюсь с baseHttpServer
FishHook
import urlparse
s = "pilot?user=%3F+%3F+&txtName=123+124 HTTP/1.1"
d = urlparse.parse_qs(s)
print (d)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB