first commit

This commit is contained in:
2024-10-29 16:09:13 +03:00
commit 8bdd4be9b0
42 changed files with 2605 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import lxml
import requests
from bs4 import BeautifulSoup
headers = {
'User-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36'
}
def get_bitcoin(url):
response = requests.get(url=url, headers=headers)
soup = BeautifulSoup(response.text, 'lxml')
bitcoin_USD = soup.find('div', class_='chart__subtitle js-chart-value').text.strip()[:10:].strip()
bitcoin_USD_STR = f'BTC/USD: ({bitcoin_USD}$)'
return bitcoin_USD_STR
def print_bitcoin():
bitcoin_USD = get_bitcoin(url='https://www.rbc.ru/crypto/currency/btcusd')
return bitcoin_USD
def main():
bitcoin_USD_STR = get_bitcoin(url='https://www.rbc.ru/crypto/currency/btcusd')
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,26 @@
import lxml
import requests
from bs4 import BeautifulSoup
headers = {
'User-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36'
}
def get_location(url):
response = requests.get(url=url, headers=headers)
soup = BeautifulSoup(response.text, 'lxml')
bitcoin_USD = soup.find('div', class_='chart__subtitle js-chart-value').text.strip()[:10:].strip()
bitcoin_USD_STR= f'BTC/USD: ({bitcoin_USD}$)'
return bitcoin_USD_STR
def print_bitcoin():
bitcoin_USD = get_location(url='https://www.rbc.ru/crypto/currency/btcusd')
#print(bitcoin_USD)
return bitcoin_USD
def main():
bitcoin_USD_STR = get_location(url='https://www.rbc.ru/crypto/currency/btcusd')
print(bitcoin_USD_STR)
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,71 @@
from config import open_weather_API_token
from pprint import pprint
import datetime
import time
import requests
def get_weather(city, open_weather_API_token):
code_to_smile = {
"Clear": "Ясно \U00002600",
"Clouds": "Облачно \U00002601",
"Rain": "Дождь \U00002614",
"Drizzle": "Дождь \U00002614",
"Thunderstorm": "Гроза \U000026A1",
"Snow": "Снег \U0001F328",
"Mist": "Туман \U0001F32B"
}
try:
r = requests.get(
f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={open_weather_API_token}&units=metric"
)
# days_ago = int(time.time()) - (86400 * (n == 1))
# r_2 = requests.get(
# f"https://api.openweathermap.org/data/2.5/onecall/timemachine?lat=55.7522&lon=37.6156&dt={days_ago}&appid={open_weather_API_token}&units=metric&lang=ru"
# )
data = r.json()
# data_2 = r_2.json()
#pprint(data)
city = data["name"]
cur_weather = data["main"]["temp"]
weather_description = data["weather"][0]["main"]
if weather_description in code_to_smile:
wd = code_to_smile[weather_description]
else:
wd = "Я понятия не имею, что у тебя там творится, выгялни в окно и посмотри!"
humidity = data["main"]["humidity"]
pressure = data["main"]["pressure"]
wind = data["wind"]["speed"]
sunrise_timestamp = datetime.datetime.fromtimestamp(data["sys"]["sunrise"])
sunset_timestamp = datetime.datetime.fromtimestamp(data["sys"]["sunset"])
length_of_the_day = sunset_timestamp - sunrise_timestamp
print(f"***{datetime.datetime.now().strftime('%Y-%m-%d %H:%M')}***\n"
f"Погода в городе: {city}\nТемпература: {cur_weather}{wd}\n"
f"Влажность: {humidity}%\nДавление: {pressure} мм.рт.ст\n"
f"Ветер: {wind} м/c\nВосход солнца: {sunrise_timestamp}\n"
f"Закат солнца: {sunset_timestamp}\nПродолжительность дня: {length_of_the_day}\n"
f"Хорошего дня!")
except Exception as ex:
print(ex)
print("Проверьте название города")
# def print_weather(city, open_weather_API_token):
# weather = get_weather(city, open_weather_API_token):
# return weather
def main():
city = input('Введите город: ')
#n = int(input('Сколько дней назад: '))
get_weather(city, open_weather_API_token)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,3 @@
хуй
блять
пизда

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
import json
ar = []
with open('censorship.txt', encoding='utf-8') as read_file:
for i in read_file:
n = i.lower().split("\n")[0]
if n != "":
ar.append(n)
with open('censorship.json', "w", encoding='utf-8') as write_file:
json.dump(ar, write_file)
# with open('name_dict.txt', encoding='utf-8') as read_file:
# for i in read_file:
# n = i.lower().split("\n")[0]
# if n != "":
# ar.append(n)
# with open('name_dict.json', "w", encoding='utf-8') as write_file:
# json.dump(ar, write_file)