Skip to content

Instantly share code, notes, and snippets.

@jlggross
jlggross / sorteio.c
Created October 25, 2013 16:29
Realiza o sorteio de 1 a 5
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main () {
int iSecret;
srand (time(NULL));
iSecret = rand() % 5 + 1;
@jlggross
jlggross / BTCscrapping-driver.py
Last active July 30, 2020 21:25
Creating a driver to access an URL
from selenium import webdriver
driver = webdriver.Chrome()
url = "https://www.btgpactualdigital.com/renda-variavel/venda-descoberta"
driver.get(url)
xpath = "/html/body/app-root/div/app-variable-sale/section/app-variable-assets-list/section/div/div[2]/div/ul/li[1]"
@jlggross
jlggross / BTCscrapping-find-elements.py
Created July 30, 2020 22:04
Getting all elements with Selenium webdriver
elements = driver.find_elements_by_xpath(xpath[:-3])
for element in elements:
print(element.text)
@jlggross
jlggross / BTCscrapping-find-elements-wait.py
Last active July 30, 2020 22:15
Waiting the element to be created
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
xpath = "/html/body/app-root/div/app-variable-sale/section/app-variable-assets-list/section/div/div[2]/div/ul/li[1]"
# Wait 20 seconds until the element is created
try:
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, xpath)))
@jlggross
jlggross / BTCscrapping-creating-df.py
Created July 30, 2020 22:17
Creation of DataFrame after scrapping is complete
import pandas as pd
df = pd.DataFrame(columns=["Ação", "Taxa %"])
for i, element in enumerate(elements):
if len(element.text) < 11: # If any li is empty
continue
newElement = {}
newElement["Ação"] = element.text.split("\n")[0]
newElement["Taxa %"] = element.text.split("\n")[1]
@jlggross
jlggross / python_operators01.py
Created August 11, 2020 12:14
Operator comparison Python - part 01
x = 10
y = 10
print(x == y)
# True
print(x is y)
# True
@jlggross
jlggross / python_operator02.py
Created August 11, 2020 12:17
Operators comparison in Python - Part 2
x = 10000
y = 10000
print(x == y)
# True
print(x is y)
# False
@jlggross
jlggross / python_operators03.py
Last active August 11, 2020 12:19
Operators comparison in Python - Part 03
x = []
y = []
print(x == y)
# True
print(x is y)
# False
@jlggross
jlggross / python_operators04.py
Created August 11, 2020 12:21
Operators comparison in Python - Part 04
x = 10000
y = x
print(x == y)
# True
print(x is y)
# True
@jlggross
jlggross / id_function.py
Created August 11, 2020 12:46
Print the id of and object
X = 10
print(id(x))
# 140002029632144
x = 10000
print(id(x))
# 140001888536400
x = []
print(id(x))
# 140001888523016