Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block findcep

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
#!/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')
#!/usr/bin/env python
import requests
API_ADDRESS_BASE_URL = '{uf}/{cidade}/{endereco}'
HEADERS = {'Referer': ''}
def validate_field(field):
''' normalize string with replace of all spaces or tabs for "+" '''
return "+".join(field.split())
View findcep.js
const validate_cep = (cep) => {
cep = cep.replace(/[^0-9]/gi, "");
if (cep.length == 8) {
return cep;
throw `CEP "${cep}" format invalid`
const apiCep = (cep) => `${cep}.json`
let cep_search = validate_cep('01001-001');
You can’t perform that action at this time.