ich würde gerne ein Formular im web mit einem Python Skript ausfüllen und die anschließend zurück gelieferte HTML Seite in einer Datei speichern (letzteres ist kein Problem). Ich bin in diesem Zusammenhang schon auf die folgende Funktion gestoßen:
Code: Alles auswählen
def post_multipart(host, selector, fields, files):
"""
Post fields and files to an http host as multipart/form-data.
fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data to be uploaded as files
Return the server's response page.
"""
content_type, body = encode_multipart_formdata(fields, files)
h = httplib.HTTP(host)
h.putrequest('POST', selector)
h.putheader('content-type', content_type)
h.putheader('content-length', str(len(body)))
h.endheaders()
h.send(body)
errcode, errmsg, headers = h.getreply()
return h.file.read()
Bin für jede Hilfe dankbar,
cowboy