Skip to content

Instantly share code, notes, and snippets.

View DxDiagDx's full-sized avatar
:octocat:

Evgeny Lukin DxDiagDx

:octocat:
View GitHub Profile
import csv
import requests
import json
def get_json():
url = "https://www.ozon.ru/api/composer-api.bx/page/json/v2" \
"?url=/product/avtomaticheskaya-kofemashina-inhouse-rozhkovaya-coffee-arte-icm1507-seryy-397529235/"
response = requests.get(url=url)
with open('ozon_1.json', 'w', encoding='utf-8') as file:
@DxDiagDx
DxDiagDx / flashscore.py
Created October 10, 2022 05:49
Flashscore — парсим статистику с помощью Python
import json
import requests
from datetime import datetime
headers = {"x-fsign": "SW9D1eZo"}
def main():
feed = 'f_1_-1_3_ru_5'
@DxDiagDx
DxDiagDx / get_my_ip.py
Last active July 20, 2023 18:17
Python узнать свой IP-адрес
import requests
response = requests.get('http://jsonip.com')
ip = response.json()['ip']
print('Your public IP is:', ip)
@DxDiagDx
DxDiagDx / get_images.py
Last active April 5, 2023 04:38
Python: скачать и переименовать изображения для интернет-магазина
import csv
from pathlib import Path
import requests
from transliterate import slugify
def download_image(image_url, image_name):
# получаем расширение файла изображения из url
# и добавлем его к имени изображения
image_name += Path(image_url).suffix
@DxDiagDx
DxDiagDx / environs
Created January 13, 2023 08:56
environs - Переменные окружения Python
from dataclasses import dataclass
from environs import Env
@dataclass
class Bots:
bot_token: str
admin_id: str
@DxDiagDx
DxDiagDx / webscrapper.json
Created October 14, 2021 08:59
avito.ru - Webscrapper Sitemap
{"_id":"avito","startUrl":["https://www.avito.ru/krasnodar/kvartiry/sdam/na_dlitelnyy_srok/2-komnatnye-ASgBAQICAkSSA8gQ8AeQUgFAzAgUkFk?cd=1&p=[1-6]"],"selectors":[{"delay":0,"id":"adv","multiple":true,"parentSelectors":["_root"],"selector":"div.iva-item-list-H_dpX","type":"SelectorElement"},{"delay":0,"id":"link","multiple":false,"parentSelectors":["adv"],"selector":"a.link-link-MbQDP[itemprop='url']","type":"SelectorLink"},{"delay":0,"id":"price","multiple":false,"parentSelectors":["adv"],"regex":"","selector":"span.price-text-E1Y7h","type":"SelectorText"}]}
@DxDiagDx
DxDiagDx / db.py
Last active November 24, 2022 05:38
Скрипт для работы с базой данных SQLite
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()))
@DxDiagDx
DxDiagDx / services.py
Created November 7, 2022 07:46
Python - services.py - Вспомогательные функции для парсинга сайтов
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',
}
@DxDiagDx
DxDiagDx / get_data_with_mysql.py
Created October 26, 2022 12:31
WooCommerce - MySQL - Python: получить информацию о товарах из базы данных
from sshtunnel import SSHTunnelForwarder
import pymysql
host = 'test.beget.tech'
login = 'test'
password = 'test'
user_db = 'test_db'
password_db = 'test'
@DxDiagDx
DxDiagDx / functions.php
Last active October 19, 2022 05:27
СДЭК: вставить карту пунктов самовывоза
add_action( 'wp_head', 'sdek_script' );
function sdek_script() {
?>
<script id="ISDEKscript" type="text/javascript" src="https://widget.cdek.ru/widget/widjet.js" charset="utf-8"></script>
<?php
}