This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"by":"symbol", | |
"valid_key":true, | |
"results":{ | |
"MGLU3":{ | |
"symbol":"MGLU3", | |
"name":"Magaz Luiza", | |
"company_name":"Magazine Luiza S.A.", | |
"document":"47.960.950/0001-21", | |
"description":"Somos Uma Rede Varejista E Atuamos Com Foco Na Comercialização de Bens Duráveis No Brasil.", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import django | |
django.setup() | |
from apscheduler.schedulers.background import BackgroundScheduler | |
scheduler = BackgroundScheduler() | |
@scheduler.scheduled_job('interval', minutes=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db.models import Prefetch | |
def get_queryset(self): | |
if self.action_map.get('get') == 'list': | |
return CuttingLine.objects.all().select_related( | |
'line', 'line__machine_type', | |
).defer('description', 'price') | |
return CuttingLine.objects.all().select_related( | |
'line', 'line__machine_type', 'picture_primary', 'picture_pack_360' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import aiohttp | |
from pymongo import MongoClient | |
MONGO_URL = 'mongodb://localhost:27017/' | |
db_name = 'marvelCrawler' | |
db = MongoClient(MONGO_URL)[db_name] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql -u root -p"root" old_db_name -sNe 'show tables' | while read table; | |
do mysql -u root -p"root" -sNe "RENAME TABLE old_db_name.$table TO new_db_name.$table"; | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from lxml import etree | |
URL = 'http://www.buscacep.correios.com.br/sistemas/buscacep/resultadoBuscaCepEndereco.cfm' | |
def busca_cep(cep): | |
r = requests.post(URL, data=dict(relaxation=cep, tipoCEP='ALL', semelhante='N')) | |
tabela = etree.HTML(r.text).find(".//table[@class='tmptabela']") | |
logradouro, bairro, cidade_uf, cep = (x.text.strip() for x in tabela.findall('.//td')) | |
cidade, _, uf = cidade_uf.rpartition('/') |