Skip to content

Instantly share code, notes, and snippets.

View luxu's full-sized avatar
🏠
Working from home

Luciano da Silva Martins luxu

🏠
Working from home
View GitHub Profile
@luxu
luxu / cinema.py
Last active March 27, 2019 12:08
# -*- coding: utf-8 -*-
import scrapy
import re
from urllib.parse import urlparse, parse_qs
class CinemaSpider(scrapy.Spider):
name = 'cinema'
def start_requests(self):
@luxu
luxu / pagination.html
Last active December 18, 2019 18:40
example pagination in Django
<div class="row text-center">
<div class="col-lg-12">
<ul class="pagination">
{% if page_obj.has_previous %}
<li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}{% if request.GET.q %}&q={{ request.GET.q }}{% endif %}">&laquo;</a></li>
{% endif %}
{% for pg in page_obj.paginator.page_range %}
<!-- Sempre mostra as 3 primeiras e 3 últimas páginas -->
{% if pg == 1 or pg == 2 or pg == 3 or pg == page_obj.paginator.num_pages or pg == page_obj.paginator.num_pages|add:'-1' or pg == page_obj.paginator.num_pages|add:'-2' %}
@luxu
luxu / selectt
Created September 12, 2019 15:16
<q-select dense bottom-slots stack-label
class="q-mt-xl"
style="max-width: 600px"
v-model="selectedclient"
use-input
input-debounce="0"
@change="changeClient($event)"
:options="options"
@filter="filterFn"
behavior="menu"
@luxu
luxu / view
Created September 16, 2019 11:38
def gastosPorMesView(request):
template = "website/gastosPorMes.html"
qs = Gasto.objects.all() # Use the Pandas Manager
if request.method == 'POST':
request.POST.get('dtInicial')
df = qs.filter(comercio_id=1) \
.to_dataframe(['id', 'name', 'comercio_id', 'datagasto', 'valor'], index='datagasto')
"""Format the column headers for the Bootstrap table,
they're just a list of field names,
duplicated and turned into dicts like this: {'field': 'foo', 'title: 'foo'}
@luxu
luxu / html
Created September 16, 2019 11:38
<form action="#" method="POST" class="form-inline">
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="inputGroupSelect01">Tipos</label>
</div>
<select name="comercio_id" class="custom-select" id="inputGroupSelect01">
<option selected>Escolha...</option>
{% for comercio in comercios %}
<option value="{{ comercio.id }}">{{ comercio.name }}</option>
{% endfor %}
@luxu
luxu / get_dolar_site_globo.py
Last active December 18, 2019 18:38
site Valor da Globo
import pandas as pd
from bs4 import BeautifulSoup
import win32com.client as win32
from requests import get
import lxml.html
from pprint import pprint
url = 'https://valor.globo.com/'
# html = urlopen(url)
response = get(url)
@luxu
luxu / countries.py
Created December 18, 2019 18:22
Example de table simples
from bs4 import BeautifulSoup
import requests
from collections import OrderedDict
def importa(url, tmout=2):
page = requests.get(url=url, timeout=tmout)
soup = BeautifulSoup(page.content, 'html.parser')
#print('\nsoup >>>', soup)
table = soup.find_all(id="countries")[0]
result = []
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as CondicaoExperada
from selenium.common.exceptions import *
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
from time import sleep
import os, random
from requests import get
import lxml.html
url_iphone = 'https://www.amazon.com.br/s?k=iphone&__mk_pt_BR=%C3%85M%C3%85%C5%BD%C3%95%C3%91&ref=nb_sb_noss_2'
xpath_box = "//div[@class='a-section a-spacing-medium']"
xpaht_search = '//*[@id="twotabsearchtextbox"]'
xpath_name_product = '//div/h2/a/span'
xpath_price_product = "//span[@class='a-offscreen']"
# xpath_price_product = "//span[@data-a-color='base']"
FROM python:3.6.10
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
RUN pip install --upgrade pip
COPY requirements/ /code/requirements/
RUN pip install -r requirements/dev.txt