Skip to content

Instantly share code, notes, and snippets.

Avatar

Evgeny Lukin DxDiagDx

View GitHub Profile
@DxDiagDx
DxDiagDx / webscrapper.json
Created Oct 14, 2021
avito.ru - Webscrapper Sitemap
View webscrapper.json
{"_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 / functions.php
Last active Oct 5, 2021
Woo: вывести значения атрибута в коротком описании карточки товара
View functions.php
/*
* Вывод атрибутов в коротком описании
*/
add_action( 'woocommerce_single_product_summary', 'show_attr_singe_product', 21 );
function show_attr_singe_product() {
global $product;
// Получаем элементы таксономии атрибута color
$attribute_names = get_the_terms($product->get_id(), 'pa_color');
$attribute_name = "pa_color";
if ($attribute_names) {
@DxDiagDx
DxDiagDx / functions.php
Last active Jul 26, 2021
Woo: Custom text on checkout page / Свой текст на странице оформления заказа
View functions.php
/**
* Текст на странице оформления заказа
*/
add_filter('woocommerce_thankyou_order_received_text', 'woo_my_thankyou_order_received_text' );
function woo_my_thankyou_order_received_text() {
return 'Спасибо. Ваш заказ был принят.</br>В ближайшее время с вами свяжется менеджер для подтверждения.';
}
@DxDiagDx
DxDiagDx / parser-email.py
Last active Jul 26, 2021
Парсер email
View parser-email.py
import requests
import csv
import re
def get_html(url):
try:
result = requests.get(url)
result.raise_for_status()
return result.text
@DxDiagDx
DxDiagDx / functions.php
Created Jul 21, 2021
Woo: вывести в карточке товара ссылки на другие товары (через апсейл)
View functions.php
/* Карточка товара */
// Короткое описание
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
function woocommerce_template_single_excerpt() {
global $product;
$upsale_products = $product->get_upsell_ids();
if ( !empty($upsale_products) ) {
@DxDiagDx
DxDiagDx / functions.php
Created May 19, 2021
WooCommerce: добавить вкладку со ссылкой на страницу
View functions.php
/**
* Добавляем вкладку «Оплата и доставка» в карточке товара (фронтенд)
*/
add_filter('woocommerce_product_tabs','add_tabs');
function add_tabs($tabs){
$tabs[ 'payment_delivery' ] = array(
'title' => 'Оплата и доставка',
@DxDiagDx
DxDiagDx / app.py
Created May 3, 2021
WordPress + Python: удалить пост
View app.py
import requests
import base64
url = "https://wholeblogs.com/wp-json/wp/v2/posts/"
postID = '1'
user = "your-username"
password = "your-application-password"
credentials = user + ':' + password
token = base64.b64encode(credentials.encode())
@DxDiagDx
DxDiagDx / app.py
Last active May 3, 2021
WordPress + Python: редактировать пост
View app.py
import requests
import base64
url = "https://wholeblogs.com/wp-json/wp/v2/posts/"
postID = '1'
user = "your-username"
password = "your-application-password"
credentials = user + ':' + password
token = base64.b64encode(credentials.encode())
@DxDiagDx
DxDiagDx / app.py
Created May 3, 2021
WordPress + Python: создать пост
View app.py
import requests
import base64
url = "https://wholeblogs.com/wp-json/wp/v2/posts"
user = "your-username"
password = "your-application-password"
credentials = user + ':' + password
token = base64.b64encode(credentials.encode())
header = {'Authorization': 'Basic ' + token.decode('utf-8')}
post = {
@DxDiagDx
DxDiagDx / python-test.py
Last active May 3, 2021
WordPress + Python: авторизация
View python-test.py
import requests
import json
import base64
url = "https://example.com/wp-json/wp/v2/posts"
user = "your-username"
password = "your-application-password"
credentials = user + ':' + password
token = base64.b64encode(credentials.encode())
header = {'Authorization': 'Basic ' + token.decode('utf-8')}