first commit
This commit is contained in:
28
bot.0.1/other_packages/used_programs/BITCOIN_RUB1.py
Executable file
28
bot.0.1/other_packages/used_programs/BITCOIN_RUB1.py
Executable 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()
|
||||
26
bot.0.1/other_packages/used_programs/BITCOIN_USD.py
Executable file
26
bot.0.1/other_packages/used_programs/BITCOIN_USD.py
Executable 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()
|
||||
71
bot.0.1/other_packages/used_programs/open_weather_API.py
Executable file
71
bot.0.1/other_packages/used_programs/open_weather_API.py
Executable 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}C° {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()
|
||||
0
bot.0.1/other_packages/used_programs/to_json/__init__.py
Executable file
0
bot.0.1/other_packages/used_programs/to_json/__init__.py
Executable file
0
bot.0.1/other_packages/used_programs/to_json/censorship.json
Executable file
0
bot.0.1/other_packages/used_programs/to_json/censorship.json
Executable file
3
bot.0.1/other_packages/used_programs/to_json/censorship.txt
Executable file
3
bot.0.1/other_packages/used_programs/to_json/censorship.txt
Executable file
@@ -0,0 +1,3 @@
|
||||
хуй
|
||||
блять
|
||||
пизда
|
||||
1
bot.0.1/other_packages/used_programs/to_json/name_dict.json
Executable file
1
bot.0.1/other_packages/used_programs/to_json/name_dict.json
Executable file
File diff suppressed because one or more lines are too long
1344
bot.0.1/other_packages/used_programs/to_json/name_dict.txt
Executable file
1344
bot.0.1/other_packages/used_programs/to_json/name_dict.txt
Executable file
File diff suppressed because it is too large
Load Diff
17
bot.0.1/other_packages/used_programs/to_json/to_json.py
Executable file
17
bot.0.1/other_packages/used_programs/to_json/to_json.py
Executable 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)
|
||||
Reference in New Issue
Block a user