httplib2

httplib2

とりあえず使ってみた

普通にGET

import httplib2
from pit import Pit
server_data = Pit.get('stg2', {'require': {'username': '',
                                           'password': '',
                                           'url_login': '',
                                           'url_venue': '',
                                           }})
http = httplib2.Http('.cache')
res, content = http.request(server_data['url_login'], 'GET')

BASIC認証あり

server_data = Pit.get('{0}_backend'.format(target),
                      {'require': {'username': '',
                                   'password': '',
                                   'url_login': '',
                                   'url_venue': '',
                                   }})
http = httplib2.Http('.cache',
                     disable_ssl_certificate_validation=True)


if is_need_basic_auth(target):
    bauth_data = Pit.get('{0}_basic'.format(target),
                         {'require': {'username': '',
                                      'password': '',
                                      }})
    http.add_credentials(bauth_data['username'], bauth_data['password'])
res, content = http.request(server_data['url_login'], 'GET')

POST送信

# login
res, content = http.request(url_login, 'GET')

backend_login_data = {'login_id': server_data['username'],
                      'password': server_data['password'],
                      }
params = urllib.urlencode(backend_login_data)
res, content = http.request(url_login, 'POST', params)

目次

このページ

inserted by FC2 system