python 调用google 段网址服务

import urllib, httplib

conn = httplib.HTTPConnection('goo.gl')
params = urllib.urlencode({'url':'http://qiye.163.com'})
conn.request('POST', '/api/shorten', headers={"Content-Type":"application/x-www-form-urlencoded"}, body=params)
result = conn.getresponse()
resultContent = result.read()

print resultContent

你可能感兴趣的:(python,Google)