Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python
import requests
def validate_field(field):
cep = "".join(field.replace("-"," ").split())
if cep.isdigit() and len(cep) == 8:
return cep
raise Exception('CEP "{field}" Format Invalid'.format(field=field))
CEP_SEARCH = validate_field('01001001')
API_CEP_BASE_URL = '{cep}.json'
headers = {'Referer': ''}
cep_request = requests.get(API_CEP_BASE_URL.format(cep=CEP_SEARCH) , headers=headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.