This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
from environs import Env | |
@dataclass | |
class Bots: | |
bot_token: str | |
admin_id: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
from typing import Dict, List, Tuple | |
def insert(database: str, table: str, column_values: Dict): | |
with sqlite3.connect(database) as conn: | |
cursor = conn.cursor() | |
columns = ", ".join(column_values.keys()) | |
values = [tuple(column_values.values())] | |
placeholders = ", ".join("?" * len(column_values.keys())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import csv | |
import time | |
import json | |
import requests | |
headers = { | |
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36', | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sshtunnel import SSHTunnelForwarder | |
import pymysql | |
host = 'test.beget.tech' | |
login = 'test' | |
password = 'test' | |
user_db = 'test_db' | |
password_db = 'test' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
from datetime import datetime | |
headers = {"x-fsign": "SW9D1eZo"} | |
def main(): | |
feed = 'f_1_-1_3_ru_5' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
response = requests.get('http://jsonip.com') | |
ip = response.json()['ip'] | |
print('Your public IP is:', ip) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import requests | |
def get_response(metod, attempts=3, pause=3, **kwargs): | |
response = None | |
for attempt in range(1, attempts + 1): | |
try: | |
if 'get' in metod: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from woocommerce import API | |
from config import consumer_key, consumer_secret, site | |
wcapi = API( | |
url=site, | |
consumer_key=consumer_key, | |
consumer_secret=consumer_secret, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from config import wcapi | |
def update_category_image(category): | |
category_id = category['category_id'] | |
data = { | |
"image": { | |
"src": category['image'] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_response(metod, endpoint=None, params=None, data=None): | |
response = None | |
for attemp in range(1, 6): | |
try: | |
if 'get' == metod.lower(): | |
response = wcapi.get(endpoint=endpoint, params=params) | |
if 'post' == metod.lower(): | |
response = wcapi.post(endpoint=endpoint, params=params, data=data) | |
except Exception as error: | |
print('Ошибка:', error) |
NewerOlder