|
6 | 6 | from datetime import date, datetime
|
7 | 7 | import requests
|
8 | 8 |
|
| 9 | +from selenium import webdriver |
| 10 | +from webdriver_manager.chrome import ChromeDriverManager |
| 11 | +from selenium.webdriver.chrome.service import Service |
| 12 | +from selenium.webdriver.common.by import By |
9 | 13 |
|
| 14 | +servico = Service(ChromeDriverManager().install()) |
| 15 | +navegador = webdriver.Chrome(service=servico) |
10 | 16 |
|
| 17 | +headers = { |
| 18 | + 'User-agent': |
| 19 | + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 ' |
| 20 | + 'Safari/537.36 ' |
| 21 | +} |
11 | 22 |
|
12 | | -# api GoogleNews - pip install GoogleNews |
13 | | -# from GoogleNews import GoogleNews |
14 | | -# noticias = GoogleNews(period='d') |
15 | | -# noticias.setlang('pt') |
16 | | -# noticias.search('petroleo') |
17 | | -# resultado = noticias.results() |
18 | | -# print(resultado) |
19 | | -# noticia1 = resultado[0] |
20 | | -# print(noticia1['desc']) |
21 | | -# print(noticia1['link']) |
22 | | -# noticia1 = resultado[1] |
23 | | -# print(noticia1['desc']) |
24 | | -# print(noticia1['link']) |
| 23 | +navegador.get('https://news.google.com/') |
25 | 24 |
|
26 | 25 |
|
| 26 | +input(':') |
27 | 27 |
|
28 | 28 | # api cotações moedas
|
29 | 29 | # cotacoes = requests.get('https://economia.awesomeapi.com.br/last/USD-BRL,EUR-BRL,BTC-BRL')
|
|
44 | 44 | # print(f'{btc} mil reais')
|
45 | 45 |
|
46 | 46 |
|
47 | | - |
48 | | - |
49 | | - |
50 | 47 | # api previsão do tempo
|
51 | | -consulta = input('Capital: ') |
52 | | -with open('arquivos/previsoes_capitais_brasil.txt', 'r', encoding="utf8") as arquivo_previsoes: |
53 | | - capitais = arquivo_previsoes.read() |
54 | | - capitais = json.loads(capitais) |
55 | | - with open('arquivos/capitais_estados.txt', 'r', encoding="utf8") as arquivo_capitais: |
56 | | - estados = arquivo_capitais.read() |
57 | | - estados = json.loads(estados) |
58 | | - for i, j in estados.items(): |
59 | | - if consulta in i: |
60 | | - estado = j |
61 | | - print(f'{consulta}/{estado}') |
62 | | - |
63 | | - consulta = capitais[consulta] |
64 | | - |
65 | | -previsao = requests.get(consulta) |
66 | | -previsao = previsao.json() |
67 | | - |
68 | | -# dia |
69 | | -data = previsao['daily'] |
70 | | -data = data['time'] |
71 | | -data = data[0] |
72 | | -data = datetime.strptime(data, '%Y-%m-%d').date() |
73 | | -data = datetime.strftime(data, '%d/%m/%Y') |
74 | | -print(f'Data: {data}') |
75 | | - |
76 | | -# temperatura mínima |
77 | | -temp_min = previsao['daily'] |
78 | | -temp_min = temp_min['temperature_2m_min'] |
79 | | -temp_min = temp_min[0] |
80 | | -print(f'Temperatura Mínima: {temp_min}') |
81 | | - |
82 | | -# temperatura máxima |
83 | | -temp_max = previsao['daily'] |
84 | | -temp_max = temp_max['temperature_2m_max'] |
85 | | -temp_max = temp_max[0] |
86 | | -print(f'Temperatura Máxima: {temp_max}') |
87 | | - |
88 | | -# precipitação |
89 | | -precipitacao = previsao['daily'] |
90 | | -precipitacao = precipitacao['precipitation_sum'] |
91 | | -precipitacao = precipitacao[0] |
92 | | -print(f'Precipitação de chuva última hora: {precipitacao} mm') |
93 | | - |
| 48 | +# consulta = input('Capital: ') |
| 49 | +# with open('arquivos/previsoes_capitais_brasil.txt', 'r', encoding="utf8") as arquivo_previsoes: |
| 50 | +# capitais = arquivo_previsoes.read() |
| 51 | +# capitais = json.loads(capitais) |
| 52 | +# with open('arquivos/capitais_estados.txt', 'r', encoding="utf8") as arquivo_capitais: |
| 53 | +# estados = arquivo_capitais.read() |
| 54 | +# estados = json.loads(estados) |
| 55 | +# for i, j in estados.items(): |
| 56 | +# if consulta in i: |
| 57 | +# estado = j |
| 58 | +# print(f'{consulta}/{estado}') |
| 59 | +# |
| 60 | +# consulta = capitais[consulta] |
| 61 | +# |
| 62 | +# previsao = requests.get(consulta) |
| 63 | +# previsao = previsao.json() |
| 64 | +# |
| 65 | +# # dia |
| 66 | +# data = previsao['daily'] |
| 67 | +# data = data['time'] |
| 68 | +# data = data[0] |
| 69 | +# data = datetime.strptime(data, '%Y-%m-%d').date() |
| 70 | +# data = datetime.strftime(data, '%d/%m/%Y') |
| 71 | +# print(f'Data: {data}') |
| 72 | +# |
| 73 | +# # temperatura mínima |
| 74 | +# temp_min = previsao['daily'] |
| 75 | +# temp_min = temp_min['temperature_2m_min'] |
| 76 | +# temp_min = temp_min[0] |
| 77 | +# print(f'Temperatura Mínima: {temp_min}') |
| 78 | +# |
| 79 | +# # temperatura máxima |
| 80 | +# temp_max = previsao['daily'] |
| 81 | +# temp_max = temp_max['temperature_2m_max'] |
| 82 | +# temp_max = temp_max[0] |
| 83 | +# print(f'Temperatura Máxima: {temp_max}') |
| 84 | +# |
| 85 | +# # precipitação |
| 86 | +# precipitacao = previsao['daily'] |
| 87 | +# precipitacao = precipitacao['precipitation_sum'] |
| 88 | +# precipitacao = precipitacao[0] |
| 89 | +# print(f'Precipitação de chuva última hora: {precipitacao} mm') |
94 | 90 |
|
95 | 91 |
|
96 | 92 | # arquivo proverbios
|
|
100 | 96 |
|
101 | 97 |
|
102 | 98 |
|
| 99 | + |
0 commit comments