def inline(c): chat_id = c.message.chat.id message_id = c.message.id if c.data == 'quit': bot.delete_message(chat_id, message_id) if c.data == 'see': main() #parsing '''Cоздание кнопок''' news = [] inline_keyboard_news = types.InlineKeyboardMarkup() for new in main_data: new = new['news'] news.append(new) for i, n in enumerate(news, 1): botton = types.InlineKeyboardButton(f'{i} : {n}', callback_data=f'{i}') btn_photo = types.InlineKeyboardButton( 'See photo', callback_data=f'see_photo{i}') inline_keyboard_news.add(botton) inline_keyboard_news.add(btn_photo) '''Отправка новостей''' msg = bot.send_message(chat_id, 'news:', reply_markup=inline_keyboard_news) '''Отправить ссылку на новость''' enumerate_ = [str(i) for i in range(1, 17)] if c.data in enumerate_: try: msg = main_data[int(c.data) - 1]['link'] bot.send_message(chat_id, f'{msg}') except IndexError: pass '''Отправить фотографию''' for i in [str(i) for i in range(1, 17)]: if c.data == f'see_photo{i}': try: msg = main_data[int(i) - 1]['photo'] if msg: bot.send_photo(chat_id, f'{msg}') else: bot.send_message(chat_id, 'Sorry, can\'t send you photo') except IndexError: pass
def do_it(link): global previous_sum previous_sum = -1 while True: try: trains = parsing.main(link) #get all information about all trains check(trains); #choose good seats except parsing.timeout_error: print("timeout_error") except parsing.number_of_trains_convert_error: print("maybe service does not work") except ValueError: print("Value Error") except: print("unexpected error") time.sleep(300) #wait
from glob import glob os.environ["CUDA_VISIBLE_DEVICES"]="0" import glob import tensorflow as tf import numpy as np from PIL import Image from utils import * from past.builtins import xrange import glob from detect_edges_image import CropLayer import argparse from parsing import main import os main() threads = tf.train.start_queue_runners(coord=coord, sess=sess) # evaluate prosessing parsing_dir = 'dataset/parse_cihp' if os.path.exists(parsing_dir): shutil.rmtree(parsing_dir) if not os.path.exists(parsing_dir): os.makedirs(parsing_dir) # Iterate over training steps. for step in range(NUM_STEPS): parsing_, scores, edge_, _ = sess.run([pred_all, pred_scores, pred_edge, update_op]) if step % 100 == 0: print('step {:d}'.format(step)) print (image_list[step]) img_split = image_list[step].split('/')
import parsing from openpyxl import load_workbook parsing.main() wb = load_workbook('deputy.xlsx') ws = wb.active def get_info(name): info = [] for row in ws.rows: if name in row[0].value: for cell in row: info.append(cell.value) a = list(cell.value) return f'ФИО: {info[0]} \nномер телефона: {info[1]} \nсостоит в {info[2]} \n' return 'Нет информации. Проверьте правильно ли написали фамилию и затем нажмите на /start'
class Deputy(Base): __tablename__ = 'deputy' id = Column(Integer, primary_key=True) fullname = Column(String) fraction = Column(String) commitet = Column(String) tel = Column(String) def __init__(self, fullname, fraction, commitet, tel): self.fullname = fullname self.fraction = fraction self.commitet = commitet self.tel = tel Base.metadata.create_all(engine) print('Table created') from parsing import main Session = sessionmaker(bind=engine) session = Session() data = main() for one_data in data: session.add(Deputy(*one_data)) print('successfully added') session.commit()
def CronParse(): main()