mirror of
https://github.com/KUlishevgeniy/c22712.git
synced 2026-09-24 08:00:22 +00:00
Телеграм Бот (Исправленный)
This commit is contained in:
@@ -4,7 +4,7 @@ from bs4 import BeautifulSoup
|
|||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.chrome.service import Service
|
from selenium.webdriver.chrome.service import Service
|
||||||
import time
|
import time
|
||||||
|
import config
|
||||||
i = 1
|
i = 1
|
||||||
s = Service("С:\DATA\ChromeDriver\chromedriver.exe")
|
s = Service("С:\DATA\ChromeDriver\chromedriver.exe")
|
||||||
browser = webdriver.Chrome(service=s)
|
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")
|
pricest = soup.find_all('span', class_="price__main-value")
|
||||||
features = soup.find_all('span', class_="product-feature-list__value")
|
features = soup.find_all('span', class_="product-feature-list__value")
|
||||||
pictures = soup.find_all('div', class_="product-picture-container")
|
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()
|
cursor = connection.cursor()
|
||||||
insert = """CREATE TABLE public.laptops(
|
insert = """CREATE TABLE public.laptops(
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import telebot
|
import telebot
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
import config
|
||||||
def execute_request(request):
|
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 = connection.cursor()
|
||||||
cursor.execute(request)
|
cursor.execute(request)
|
||||||
result = cursor.fetchall()
|
result = cursor.fetchall()
|
||||||
@@ -9,7 +10,7 @@ def execute_request(request):
|
|||||||
connection.close()
|
connection.close()
|
||||||
return result
|
return result
|
||||||
max_id = int(execute_request("select count(*) from laptops")[0][0])
|
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"])
|
@bot.message_handler(commands=["start"])
|
||||||
def start(m, res=False):
|
def start(m, res=False):
|
||||||
bot.send_message(m.chat.id, f'Привет. Введите идентификатор от 1 до {max_id}, чтобы получить данные: ')
|
bot.send_message(m.chat.id, f'Привет. Введите идентификатор от 1 до {max_id}, чтобы получить данные: ')
|
||||||
|
|||||||
Reference in New Issue
Block a user