2010-06-15 17 views

Respuesta

43

Me codificar algo como:

pycurl_connect = pycurl.Curl() 
pycurl_connect.setopt(pycurl.URL, your_url) 
pycurl_connect.setopt(pycurl.HTTPHEADER, ['header_name1: header_value1', 
              'header_name2: header_value2']) 
pycurl_connect.perform() 
+0

¿qué hay de varias cabeceras? Como una lista? – codersofthedark

+0

gracias amigo! :) – codersofthedark

3

que puedas, con HTTPHeader. acaba de proporcionar a sus cabeceras personalizadas como una lista, así:

header = ['test: yadayadayada', 'blahblahblah']

curl.setopt(pycurl.HTTPHEADER, header)

3

Trate de usar la biblioteca human_curl https://github.com/Lispython/human_curl

custom_headers = (
('Test-Header', 'fwkjenwkljbnfkjqnewfrjven3lrf'), 
('Another-Header', 'ifenwqnfe;wnfqfjlweqnnlf') 
) 

r = human_curl.get("http://stackoverflow.com", 
        headers=custom_headers) 
+0

Esto no parece ser compatible con Python 3 – Gurgeh

Cuestiones relacionadas