import requests
headers = {'user-Agent': 'Mozilla/5.0'}
getUrl = 'https://avtoved.guru/login/'
postUrl = getUrl + 'login'
data = {'login':'логин','password':'пароль'}
ses = requests.session()
ses.get(getUrl,headers=headers)
response = ses.post(postUrl,headers=headers,data=data)
if 'LogOut' in response.text:
print('Login OK!')
else:
print('Login ERROR!')
import telebot
import pyowm
owm = pyowm.OWM('')
bot = telebot.TeleBot('')
def getWeather(city):
observation = owm.weather_at_place(city)
w = observation.get_weather()
temp = w.get_temperature('celsius')["temp"]
return temp
@bot.message_handler(content_types=['text'])
def repeat_all_message(message):
try:
temp = getWeather(message.text)
bot.send_message(message.chat.id,f'Температура в {message.text} - {temp}')
except pyowm.exceptions.api_response_error.NotFoundError:
bot.send_message(message.chat.id,'Ошибка! Город не найден!')
if __name__ == '__main__':
bot.polling(none_stop=True)
import requests
headers = {'Content-Type':'application/json;charset=utf-8'}
url = 'https://www.vtb.ru/api/sitecore/coinsapi/filter'
data = '{"query":"","newCollection":false,"Discounted":false,"GiftBox":false,"Order":"priceAsc","SearchGroups":false,"CoinList":"all","Favorites":[],"Groups":["8e67bb77202c40fa8ae0258d5bcb66f8","087e7eca08724e88aa1fbd0ebb0ebf70"],"Series":[],"Themes":[],"Metals":[],"PriceMin":"","PriceMax":"","Page":1,"ResultsOnPage":16}'
response = requests.post(url,data=data,headers=headers)
import requests
headers = {'user-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0',
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
}
url = 'https://www.youtube.com/watch?v=pSWOcXg703s'
response = requests.get(url,headers=headers)
html = response.text
first_1 = html.find('og:title" content="')+19
second_2 = html.find('">',first_1)
title = html[first_1:second_2]
first = html.find('videoViewCountRenderer')+72
second = html.find('"}]}',first)
views = html[first:second]
first_ = html.find('likeStatus":"INDIFFERENT","tooltip"')+37
second_ = html.find('"}},',first_)
likes = html[first_:second_].replace(' ','').split('/')
print(f'Название видео: {title}')
print(f'Сейчас смотрят: {views}')
print(f'Лайков: {likes[0]}')
print(f'Дизлайков: {likes[1]}')
Название видео: Elon Musk Live: Bitcoin BTC Talk, BTC Mass Adoption & SpaceX update [April, 2020]
Сейчас смотрят: 59 365
Лайков: 2 542
Дизлайков: 153
https://www.avito.ru/items/phone/id_объявленияс параметрами:
import requests
import base64
params = { 'pkey':'dfed69290bc453b834e2e0e2f16bf630', # Осталось узнать, как генерируется это значение!
'vsrc':'r',
'searchHash':'ttv948zc8v4kg0oc4k0o8wok04w8ook' # И это тоже!
}
url = 'https://www.avito.ru/items/phone/1315030387'
response = requests.get(url,params=params)
with open("imageToSave.png", "wb") as fh:
fh.write(base64.decodebytes(response.text[34:-2].encode()))
def calculate():
n = int(input("Кол-во учеников: "))
k = int(input("Кол-во яблок: "))
print(f'Кол-во яблок что получил кадлый ученик: {k//n}')
print(f'Кол-во яблок осталось: {k%n}')
calculate();