Skip to content

Instantly share code, notes, and snippets.

@vicalejuri
Last active August 29, 2015 13:55
Show Gist options
  • Save vicalejuri/8692639 to your computer and use it in GitHub Desktop.
Save vicalejuri/8692639 to your computer and use it in GitHub Desktop.
def locawebJSON(data):
_pdata = []
for k,v in data.iteritems():
if type(v) in [str, unicode]:
v = ('"%s"' % (v))
elif isinstance(v, bool):
v = (v and 'true' or 'false')
_pdata.append('%s=%s' % (k,v))
return '\r\n'.join( _pdata )
u = 'http://publicador.locaweb.com.br/action/Login'
h = {'content-type': 'application/json; charset=UTF-8'}
d = {'languageName': 'en', 'password': 'acidus-orientalis', 'remember': False, 'userName': 'suavak'}
import requests
r = requests.post( u, data=locawebJSON( d ), headers=h )
r.text()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment