Skip to content

Instantly share code, notes, and snippets.

View eder-projetos-dev's full-sized avatar

Éder Luís Britto Garcia eder-projetos-dev

View GitHub Profile
@eder-projetos-dev
eder-projetos-dev / parser_bs4.py
Last active February 26, 2023 21:05
Python - Parser html com BeautifulSoup
from bs4 import BeautifulSoup
html = 'lt;p><span style="font-weight: 400;">Você não teve o e-mail pessoal criado por falta de informações, para a criação você deve abrir um novo chamado com os seguintes dados:</span></p><p><strong>CPF -</strong></p><p><strong>NOME COMPLETO - </strong></p><p><strong>MATRÍCULA -</strong></p><p><strong>CARGO -</strong></p><p><strong>TELEFONE -</strong></p><p><strong>SETOR -</strong></p>'
soup = BeautifulSoup(html, 'html5lib')
print(soup.get_text())
@eder-projetos-dev
eder-projetos-dev / html_parser_exemplo.py
Last active February 26, 2023 21:06
Python - What is the HTML parser?
from html.parser import HTMLParser
class Parser(HTMLParser):
# method to append the start tag to the list start_tags.
def handle_starttag(self, tag, attrs):
global start_tags
start_tags.append(tag)
# method to append the end tag to the list end_tags.
@eder-projetos-dev
eder-projetos-dev / exemplo_decorator.py
Last active February 26, 2023 21:07 — forked from marcoscastro/exemplo_decorator.py
Python - Exemplo simples de decorator
def maiuscula(funcao):
def wrapper(texto): # função que modifica
return funcao(texto.upper()) # transforma pra maiúscula
return wrapper # retorna a função modificadora
@maiuscula
def imprimir_mensagem(nome):
print(f"Olá {nome}, \nSeja bem vindo!")
@eder-projetos-dev
eder-projetos-dev / usuarios.py
Last active February 26, 2023 21:08
Python - Conexão com mysql e query retornando string
import mysql.connector
mydb = mysql.connector.connect(
host="127.0.1.1", # ip do banco
user="usuario",
passwd="senha",
database="banco_glpi"
)
mycursor = mydb.cursor()
@eder-projetos-dev
eder-projetos-dev / lendo_argumentos.py
Last active February 26, 2023 21:08
Python - Lendo a lista de argumentos passados para o script
import sys
try:
if sys.argv[1] in sys.argv: # Caso exista argumento 1
match sys.argv[1]:
case "oi":
print("\nOlá pessoa!")
case "tchau":
print("\nTchau, até logo!")
case _:
@eder-projetos-dev
eder-projetos-dev / comentarios-ordem-cronologica-reversa.py
Last active February 26, 2023 21:08
Python - Exibindo comentários em ordem cronológica reversa
"""
Exibindo comentários em ordem cronológica reversa.
Os mais recentes aparecem primeiro.
https://docs.python.org/3/howto/sorting.html
"""
comentarios = [
['2023-1-29 11:03:00',"Agora entendi o problema"],
['2023-1-29 11:04:01',"Quase finalizando"],
['2022-12-29 8:32:49',"Recebi sua mensagem"],
['2022-12-30 4:14:58',"Ainda não entendi o problema"],
@eder-projetos-dev
eder-projetos-dev / README.md
Last active March 3, 2023 00:43
Python - Gerador de QR Code

Pure Python QR Code Generator

pip install qrcode
pip install "qrcode[pil]"
@eder-projetos-dev
eder-projetos-dev / cotacao_btc_dolar_gist.py
Created March 3, 2023 14:17
Python - Cotação BTC em dólar com a API do CoinMarketCap
from requests import Request, Session
import json
import time
import webbrowser
import pprint
def getInfo (): # Function to get the info
url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest' # Coinmarketcap API url
@eder-projetos-dev
eder-projetos-dev / README.md
Last active March 4, 2023 01:07
Python - Barcode generator

Barcode Generator in Python

Install python-barcode

pip install python-barcode

Test

#!/usr/bin/env python
@eder-projetos-dev
eder-projetos-dev / coinmarketcap-python.md
Last active March 4, 2023 20:47 — forked from SrNightmare09/coinmarketcap-api.md
Python - Using Coinmarketcap API

Using Coinmarketcap API with Python

This is a Gist for anyone looking to learn everything about retrieving cryptocurrency data from Coinmarketcap.com. A handful of information is provided here - Getting started, how to get the API key, what problems I faced, the API limitations and many others...