<jupyter_start><jupyter_text>Intensivao de Python - Aula4<jupyter_code>from selenium import webdriver
from selenium.webdriver.common.keys import Keys
navegador = webdriver.Chrome()
#navegador.get('https://www.hashtagtreinamentos.com/category/python')
#copy XPath
navegador.get('https://www.google.com/')
navegador.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input').send_keys('cotacao dolar')
navegador.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input').send_keys(Keys.ENTER)
cotacao_dolar = navegador.find_element_by_xpath('//*[@id="knowledge-currency__updatable-data-column"]/div[1]/div[2]/span[1]').get_attribute('data-value')
print(cotacao_dolar)
navegador.get('https://www.google.com/')
navegador.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input').send_keys('cotacao euro')
navegador.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input').send_keys(Keys.ENTER)
cotacao_euro = navegador.find_element_by_xpath('//*[@id="knowledge-currency__updatable-data-column"]/div[1]/div[2]/span[1]').get_attribute('data-value')
print(cotacao_euro)
navegador.get('https://www.melhorcambio.com/ouro-hoje#:~:text=O%20valor%20do%20grama%20do,em%20R%24%20280%2C60.')
cotacao_ouro = navegador.find_element_by_xpath('//*[@id="comercial"]').get_attribute('value')
cotacao_ouro = cotacao_ouro.replace(',', '.')
print(cotacao_ouro)
import pandas as pd
df = pd.read_excel(r'Produtos.xlsx')
df.head()
df.info()
df.loc[df['Moeda'] == 'Dólar', 'Cotação'] = float(cotacao_dolar)
df.loc[df['Moeda'] == 'Euro', 'Cotação'] = float(cotacao_euro)
df.loc[df['Moeda'] == 'Ouro', 'Cotação'] = float(cotacao_ouro)
df.head(10)
df['Preço Base Reais'] = df['Preço Base Original'] * df['Cotação']
df['Preço Final'] = df['Preço Base Reais'] * df['Margem']
df
df.to_excel('Produto_atualizado.xlsx', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21221374045801528, 'fraction_numerical': 0.02697201017811705, 'mean_word_length': 8.144186046511628, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '125406', 'license': 'MIT', 'n_tokens_mistral': 884, 'n_tokens_neox': 848, 'n_words': 73, 'path': 'HastagTreinamentos/IntensivaoAula4.ipynb', 'repo_name': 'robsonavr/python', 'size': '1965'}