독도 광고 모금 캠페인


'httplib2'에 해당되는 글 1건

  1. 2008/04/17 handling cookies with httplib2 and urlib2
2008/04/17 00:15

handling cookies with httplib2 and urlib2

#!/usr/bin/env python
import urllib
import httplib2

http = httplib2.Http()
url = 'http://www.example.com/login'
body = {'USERNAME': 'foo', 'PASSWORD': 'bar'}

# POST
headers = {'Content-type': 'application/x-www-form-urlencoded'}
response, content = http.request(url, 'POST', headers=headers, body=urllib.urlencode(body))


# GET
headers = {'Cookie': response['set-cookie']}
url = 'http://www.example.com/home'
response, content = http.request(url, 'GET', headers=headers)
Trackback 0 Comment 0