def extract_content_category(category_id, category_name, conn):
    category_data = category.category()
    category_data.category_id = category_id
    category_data.category_name = category_name
    categories_leaf = category_data.get_leaf_category_by_root(category_id, conn)
    for category_item in categories_leaf:
        print(category_item)
Esempio n. 2
0
def get_child_category(category_id):
    data_product = product.product().get_all_product_by_category(
        (category_id, ), conn)
    child_categories = category.category().get_child_category((category_id, ),
                                                              conn)
    return render_template('index.html',
                           parent_id=category_id,
                           products=data_product,
                           categories=data_category,
                           child_categories=child_categories)
def extract_category_info(conn, category_item, idx ):
    print('start extract data from thread: ', idx)
    if conn == 0:
        conn = psycopg2.connect(tiki_info.db_connection)

    global counts

    category_data = category.category()
    category_data.category_link = category_item.a['href']
    category_data.category_name = category_item.select("span.text")[0].get_text()
    stored_row = category_data.get_sub_category(conn)
    
    for key in stored_row.keys():
            counts[key] += stored_row[key]
Esempio n. 4
0
def cancel_job():
    print('Starting pause job: ')
    ETL_jobs.pause_jobs()
    print('After pause. ')
    all_categories = category.category().get_parent_category(conn)
    return render_template('scrapping.html', all_categories=all_categories)
Esempio n. 5
0
def scrapping():
    all_categories = category.category().get_parent_category(conn)
    return render_template('scrapping.html', all_categories=all_categories)
Esempio n. 6
0
from flask import Flask, render_template, render_template_string
import json
from packages.object_scrapping import product, category
import psycopg2
import app, constants.tiki_information as tiki_info
# from flask_menu import Menu, register_menu

conn = psycopg2.connect(tiki_info.db_connection)
data_category = category.category().get_parent_category(conn)
app = Flask(__name__, template_folder="templates")


@app.route('/')
@app.route('/home')
def index():
    data_product = product.product().get_all_product_by_category(
        data_category[0][0], conn)
    return render_template('index.html',
                           products=data_product,
                           categories=data_category)


@app.route('/product/<int:category_id>', methods=['GET', 'POST'])
def get_product(category_id):
    data_product = product.product().get_all_product_by_category(
        (category_id, ), conn)
    return render_template('index.html',
                           products=data_product,
                           categories=data_category)