Consulta de CPF e CNPJ na Receita Federal com Web-Scraping

Overview

Consulta de CPF e CNPJ na Receita Federal com Web-Scraping

Repositório contendo scripts Python que realizam a consulta de CPF e CNPJ diretamente no site da Receita Federal.

Requerimentos

  • Python 3.x instalado;
  • Driver do navegador que será utilizado. Clique aqui para mais informações;
  • Caminho do driver baixado adicionado ao PATH.

Instalação

Na pasta do repositório, execute o comando:

pip install -r requirements.txt

Alterações necessárias

Para a execução, é necessário adaptar o código para o navegador que será utilizado. Por padrão o código utiliza o navegador Microsoft Edge. Modificar se necessário:

  • Importações dos módulos. Mudar edge para o navegador que será usado:
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options
  • Caminho do driver baixado:
PATH_TO_DRIVER = "C:/edge_driver/msedgedriver.exe"
  • Inicialização do webdriver. Mudar Edge para o navegador que será usado:
driver = webdriver.Edge(service=serv, service_log_path="NUL", options=options)

Consulta de CNPJ - Exemplo

Na pasta do repositório, execute o comando:

python cnpj/consulta_cnpj.py

Digite os campos necessários:

Digite o CNPJ (somente números): 06990590000395
Digite os caracteres da imagem exibida: ZaQO5z

Com os dados inseridos corretamente, a consulta exibirá um JSON de retorno:

{
    "cnpj": "06.990.590/0003-95",
    "tipo_empresa": "FILIAL",
    "data_abertura": "11/01/2008",
    "nome_empresarial": "GOOGLE BRASIL INTERNET LTDA.",
    "nome_fantasia": "********",
    "endereco": {
        "logradouro": "AV DOS ANDRADAS",
        "numero": "3000",
        "complemento": "ANDAR 5 14 15 16 17 EDIF BOULEVARD CORPORATE",
        "cep": "30.260-070",
        "bairro": "SANTA EFIGENIA",
        "municipio": "BELO HORIZONTE",
        "estado": "MG"
    },
    "email": "[email protected]",
    "telefone": "(11) 2395-8400",
    "situacao_cadastral": "ATIVA",
    "data_situacao_cadastral": "11/01/2008"
}

Consulta de CPF - Exemplo

Na pasta do repositório, execute o comando:

python cpf/consulta_cpf.py

Digite os campos necessários:

Digite o CPF (somente números): 12345678901
Digite a data de nascimento (DD/MM/AAAA): 25/12/2000
Digite os caracteres da imagem exibida: 9XETCm

Com os dados inseridos corretamente, a consulta exibirá um JSON de retorno:

{
    "cpf": "123.456.789-01",
    "nome": "FULANO BELTRANO CICLANO",
    "data_nascimento": "25/12/2000",
    "situacao_cadastral": "REGULAR",
    "data_inscricao": "12/04/2006",
    "digito_verificador": "00"
}
You might also like...
Web Scraping Practica With Python

Web-Scraping-Practica Integrants: Guillem Vidal Pallarols. Lídia Bandrés Solé Fitxers: Aquest document és el primer que trobem. A continuació trobem u

Here I provide the source code for doing web scraping using the python library, it is Selenium.
Here I provide the source code for doing web scraping using the python library, it is Selenium.

Here I provide the source code for doing web scraping using the python library, it is Selenium.

A package that provides you Latest Cyber/Hacker News from website using Web-Scraping.

cybernews A package that provides you Latest Cyber/Hacker News from website using Web-Scraping. Latest Cyber/Hacker News Using Webscraping Developed b

Web Scraping OLX with Python and Bsoup.
Web Scraping OLX with Python and Bsoup.

webScrap WebScraping first step. Authors: Paulo, Claudio M. First steps in Web Scraping. Project carried out for training in Web Scrapping. The export

Demonstration on how to use async python to control multiple playwright browsers for web-scraping

Playwright Browser Pool This example illustrates how it's possible to use a pool of browsers to retrieve page urls in a single asynchronous process. i

Google Scholar Web Scraping

Google Scholar Web Scraping This is a python script that asks for a user to input the url for a google scholar profile, and then it writes publication

This is a module that I had created along with my friend. It's a basic web scraping module
This is a module that I had created along with my friend. It's a basic web scraping module

QuickInfo PYPI link : https://pypi.org/project/quickinfo/ This is the library that you've all been searching for, it's built for developers and allows

A simple django-rest-framework api using web scraping

Apicell You can use this api to search in google, bing, pypi and subscene and get results Method : POST Parameter : query Example import request url =

Web Scraping images using Selenium and Python
Web Scraping images using Selenium and Python

Web Scraping images using Selenium and Python A propos de ce document This is a markdown document about Web scraping images and videos using Selenium

Owner
Josué Campos
I am a student of computer science at @ufv. Computer mathematics, AI, data science and IoT enthusiastic.
Josué Campos
Scrapy, a fast high-level web crawling & scraping framework for Python.

Scrapy Overview Scrapy is a fast high-level web crawling and web scraping framework, used to crawl websites and extract structured data from their pag

Scrapy project 45.5k Jan 7, 2023
Web mining module for Python, with tools for scraping, natural language processing, machine learning, network analysis and visualization.

Pattern Pattern is a web mining module for Python. It has tools for: Data Mining: web services (Google, Twitter, Wikipedia), web crawler, HTML DOM par

Computational Linguistics Research Group 8.4k Jan 8, 2023
Async Python 3.6+ web scraping micro-framework based on asyncio

Ruia ??️ Async Python 3.6+ web scraping micro-framework based on asyncio. ⚡ Write less, run faster. Overview Ruia is an async web scraping micro-frame

howie.hu 1.6k Jan 1, 2023
Web scraping library and command-line tool for text discovery and extraction (main content, metadata, comments)

trafilatura: Web scraping tool for text discovery and retrieval Description Trafilatura is a Python package and command-line tool which seamlessly dow

Adrien Barbaresi 704 Jan 6, 2023
🥫 The simple, fast, and modern web scraping library

About gazpacho is a simple, fast, and modern web scraping library. The library is stable, actively maintained, and installed with zero dependencies. I

Max Humber 692 Dec 22, 2022
Transistor, a Python web scraping framework for intelligent use cases.

Web data collection and storage for intelligent use cases. transistor About The web is full of data. Transistor is a web scraping framework for collec

BOM Quote Manufacturing 212 Nov 5, 2022
A Web Scraping Program.

Web Scraping AUTHOR: Saurabh G. MTech Information Security, IIT Jammu. If you find this repository useful. I would appreciate if you Star it and Fork

Saurabh G. 2 Dec 14, 2022
A web scraping pipeline project that retrieves TV and movie data from two sources, then transforms and stores data in a MySQL database.

New to Streaming Scraper An in-progress web scraping project built with Python, R, and SQL. The scraped data are movie and TV show information. The go

Charles Dungy 1 Mar 28, 2022
Web-Scraping using Selenium Master

Web-Scraping using Selenium What is the need of Selenium? Some websites don't like to be scrapped and in that case you need to disguise your webscrapi

Md Rashidul Islam 1 Oct 26, 2021
Scraping web pages to get data

Scraping Data Get public data and save in database This is project use Python How to run a project 1 - Clone the repository 2 - Install beautifulsoup4

Soccer Project 2 Nov 1, 2021