Skip to main content

Método para busca de dados de CEP no webservice dos Correios

Project description

PyCEP Correios
=============

[![Build Status](https://travis-ci.org/mstuttgart/pycep-correios.svg?branch=develop)](https://travis-ci.org/mstuttgart/pycep-correios)
[![Coverage Status](https://coveralls.io/repos/github/mstuttgart/pycep-correios/badge.svg?branch=develop)](https://coveralls.io/github/mstuttgart/pycep-correios?branch=develop)
[![Code Health](https://landscape.io/github/mstuttgart/pycep-correios/develop/landscape.svg)](https://landscape.io/github/mstuttgart/pycep-correios/develop)
[![PyPI](https://img.shields.io/pypi/v/pycep-correios.svg)](https://pypi.python.org/pypi/pycep-correios)
[![PyPI](https://img.shields.io/pypi/pyversions/pycep-correios.svg)](https://pypi.python.org/pypi/pycep-correios)
[![PyPI](https://img.shields.io/pypi/l/pycep-correios.svg)](https://github.com/mstuttgart/pycep-correios/blob/master/LICENSE)

O PyCEP Correios faz uso do webservice dos correios para efetuar a busca de um dado CEP fornecido pelo usuário. O retorno dessa consulta é o endereço pertencente ao CEP.

### Instalação
O PyCEP Correios pode ser facilmente instalado com o comando a seguir:

```
pip3 install pycep-correios
```

### Como usar

Consultar o endereço de um CEP é muito simples com o PyCEPCorreios. Não importa se o CEP fornecido possui hífen ou ponto. O PyCEPCorreios trata a entrada garantindo uma entrada válida para o *webservice* dos Correioss.
Veja os exemplos a seguir:

```python
from pycep_correios.correios import Correios

# Tambem pode ser usado .get_cep('37503130')
endereco = Correios.get_cep('37503130')

print(endereco['rua'])
print(endereco['bairro'])
print(endereco['cidade'])
print(endereco['complemento'])
print(endereco['uf'])
print(endereco['outro'])

# Terceiro exemplo, usando o mesmo cep usado anteriormente, porém com hífen e ponto.
endereco = Correios.get_cep('37.503-130')

print(endereco['rua'])
print(endereco['bairro'])
print(endereco['cidade'])
print(endereco['complemento'])
print(endereco['uf'])
print(endereco['outro'])

# Quarto exemplo, enviamos um cep incorreto, com o numero de digitos inferior a 8.

try:
endereco = Correios.get_cep('37.50-130')
except CorreiosCEPInvalidCEPException as exc:
print(exc.message)

```

### Contribuidores

[Aldo Soares](https://github.com/Aldo774)

### Créditos

Copyright (C) 2015-2017 por Michell Stuttgart Faria

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycep-correios-1.1.3.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycep_correios-1.1.3-py3.4.egg (9.0 kB view details)

Uploaded Egg

File details

Details for the file pycep-correios-1.1.3.tar.gz.

File metadata

File hashes

Hashes for pycep-correios-1.1.3.tar.gz
Algorithm Hash digest
SHA256 d546332f9ca5a5d4debb2da2d1f56f9bc7757def2f9b3b20315d4722b687a49b
MD5 be2cdf206b3af4ba4f2c2ab065c54316
BLAKE2b-256 e857d8a68f77a051cfec61ab3e2cf3f2de02827cb9941e7821dae3689fe78283

See more details on using hashes here.

File details

Details for the file pycep_correios-1.1.3-py3.4.egg.

File metadata

File hashes

Hashes for pycep_correios-1.1.3-py3.4.egg
Algorithm Hash digest
SHA256 2e7ab244cb7c586277e851289b4a0da38d428dc9ac7c501f283bb89625f2adfa
MD5 966c9dff0148c35862466b0f2315d690
BLAKE2b-256 000b66b7eb99eab25bf03b6b24059e35509885ae156bdee2e03135216e1aefea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page