From b50a1dccf508a4b739be9fa33cd5d803787927fa Mon Sep 17 00:00:00 2001 From: Dronminator Date: Sat, 15 Apr 2023 19:40:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D0=BB=D0=B5=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=20=D0=91=D0=BE=D1=82=20(=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Задания/task1/Lahin/postgres.py | 4 ++-- Задания/task1/Lahin/telegrambot.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Задания/task1/Lahin/postgres.py b/Задания/task1/Lahin/postgres.py index 3afaf45..fe8a029 100644 --- a/Задания/task1/Lahin/postgres.py +++ b/Задания/task1/Lahin/postgres.py @@ -4,7 +4,7 @@ from bs4 import BeautifulSoup from selenium import webdriver from selenium.webdriver.chrome.service import Service import time - +import config i = 1 s = Service("С:\DATA\ChromeDriver\chromedriver.exe") browser = webdriver.Chrome(service=s) @@ -23,7 +23,7 @@ productst = soup.find_all('a', class_="product-title__text") pricest = soup.find_all('span', class_="price__main-value") features = soup.find_all('span', class_="product-feature-list__value") pictures = soup.find_all('div', class_="product-picture-container") -connection=psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') +connection=psycopg2.connect(host=config.host, dbname=config.dbname, user=config.user, password=config.password) cursor = connection.cursor() insert = """CREATE TABLE public.laptops( id serial primary key, diff --git a/Задания/task1/Lahin/telegrambot.py b/Задания/task1/Lahin/telegrambot.py index b09b60e..ee3ac7d 100644 --- a/Задания/task1/Lahin/telegrambot.py +++ b/Задания/task1/Lahin/telegrambot.py @@ -1,7 +1,8 @@ import telebot import psycopg2 +import config def execute_request(request): - connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') + connection = psycopg2.connect(host=config.host, dbname=config.dbname, user=config.user, password=config.password) cursor = connection.cursor() cursor.execute(request) result = cursor.fetchall() @@ -9,7 +10,7 @@ def execute_request(request): connection.close() return result max_id = int(execute_request("select count(*) from laptops")[0][0]) -bot = telebot.TeleBot('5656574233:AAEU1Ggc4J1aWMtlLnphtScDd3jGCrzbuuY') +bot = telebot.TeleBot(config.bot_token) @bot.message_handler(commands=["start"]) def start(m, res=False): bot.send_message(m.chat.id, f'Привет. Введите идентификатор от 1 до {max_id}, чтобы получить данные: ')