用户工具

站点工具


python-network-application:urllib2-post

Python urllib/urllib2 实现POST方法

def get_taobao_api_data(app_para_dct):
  content = ""
  if app_para_dct:
    para_dct = {}
    para_dct['a'] = 'a'
    para_dct['b'] = 'b'
    url = """http://gw.api.taobao.com/router/rest"""
    para_data = urllib.urlencode(para_dct)
    f = urllib2.urlopen(url, para_data)
    content = f.read()
  return content
python-network-application/urllib2-post.txt · 最后更改: 2011/08/13 04:48 (外部编辑)