curl-library
Re: Simple encoding problem (perhaps :-) )
Date: Thu, 4 Nov 2004 12:17:14 +0100
On Wed, 3 Nov 2004 16:28:18 -0000, Guillaume Arluison <ga_at_lacde.net> wrote:
> I'm a python user too.
>
> Try to make your python code as simple as possible with the same problem and
> send it, Ill run it myself/see the code more clearly.
>
The site is password protected, and I have no control over the
password I am using (it is managed by another department), so
infortunately I am not authorized to give it to you. :-(
Anyway
Command line:
curl --data "H1APPA1=1000062&H1APPA2=RE0U&H1APPA3=C&H1APPA4=VC&H1APPA5=IST%23&H1APPA6=00000&H1APPA7=CONSORZIO+DI+BONIFICA+PARMIGIANA+MOGLIA+SECCHIA&H_TIPO_VIS=V&NASCOSTO=1&H_DBHOST=A&H_CATASTO=FABBRICATI,F&H_COMUNEALL=A162,RE,ALBINEA&H_SOURCE=RICERCA&H_SRCVIS=DIRETTA&TFGL=0018&TNUM=07786&TNUM1=&TSUB=&TIPODEN=0&TPROT=&TANNO=&TB2=Ricerca&ANNULLA2=Cancella"
-k --user username:password
https://web.site/servlet/NWEF00SJ
python:
pf='''H1APPA1=1000062&H1APPA2=RE0U&H1APPA3=C&H1APPA4=VC&H1APPA5=IST%23&H1APPA6=00000&H1APPA7=CONSORZIO+DI+BONIFICA+PARMIGIANA+MOGLIA+SECCHIA&H_TIPO_VIS=V&NASCOSTO=1&H_DBHOST=A&H_CATASTO=FABBRICATI,F&H_COMUNEALL=A162,RE,ALBINEA&H_SOURCE=RICERCA&H_SRCVIS=DIRETTA&TFGL=0018&TNUM=07786&TNUM1=&TSUB=&TIPODEN=0&TPROT=&TANNO=&TB2=Ricerca&ANNULLA2=Cancella'''
d= Curl()
d.post('https://web.site/servlet/NWEF00SJ', pf)
HTML=d.contents
while the Curl object is defined this way:
class Test:
def __init__(self):
self.contents = ''
def body_callback(self, buf):
self.contents = self.contents + buf
class Curl:
t = Test()
def __init__(self):
self.curl = pycurl.Curl()
self.curl.setopt(pycurl.WRITEFUNCTION, self.t.body_callback)
self.curl.setopt(pycurl.SSL_VERIFYPEER, 0)
self.curl.setopt(pycurl.NOSIGNAL, 1)
self.curl.setopt(pycurl.CONNECTTIMEOUT, 30)
self.curl.setopt(pycurl.TIMEOUT, 300)
self.curl.setopt(pycurl.USERPWD, username:password)
def post(self, url, postdata):
self.curl.setopt(pycurl.URL, url)
self.curl.setopt(pycurl.VERBOSE, 0)
self.curl.setopt(pycurl.POSTFIELDS, postdata)
self.curl.perform()
self.contents=self.t.contents
>
> ''' means 3 times the single [']
I already tried it. No luck.
Thank you for your kindness. Anyway I am rather sure it is an encoding
problem. If I mangle the IST field from the CUrl command line, I get
the same wrong result I have from libCUrl
-- Ciao NicoReceived on 2004-11-04