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 logging | |
import os | |
from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove, Update | |
from telegram.ext import ( | |
Updater, CommandHandler, MessageHandler, Filters, ConversationHandler, CallbackContext | |
) | |
from scrapping import * | |
from mail import * | |
import requests |
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 main(): | |
'''Start Bot''' | |
# Launch Updater | |
updater = Updater("{}".format(TOKEN), use_context=True) | |
# Get the dispatcher to register handlers | |
dispatcher = updater.dispatcher | |
# conversions handled by command | |
dispatcher.add_handler(CommandHandler("start", start)) |
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 photo(update: Update, context: CallbackContext): | |
user = update.message.from_user | |
photo_file = update.message.photo[-1].get_file() | |
# photo_file.download('user_photo.jpg') | |
# Get link to get file_path | |
link1 = "https://api.telegram.org/bot{}/getfile?file_id={}".format(TOKEN, photo_file.file_id) | |
r = requests.get(link1) | |
file_path = r.json()["result"]["file_path"] |
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 | |
from selenium import webdriver | |
from bs4 import BeautifulSoup as soup | |
# Chromedrive setting | |
chrome_options = webdriver.ChromeOptions() | |
chrome_options.add_argument("--headless") | |
chrome_options.add_argument("--disable-dev-shm-usage") | |
chrome_options.add_argument("--no-sandbox") | |
chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN") |
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 from_to(fr, to): | |
# create irl | |
url = 'https://www.google.fr/maps/dir/{}/{}/data=!4m2!4m1!3e0'.format(fr, to) | |
# Connect to the page | |
driver.get(url) | |
# Wait 1 sec to ensure full page is loaded | |
time.sleep(1) | |
# Soupify source code | |
page_soup = soup(driver.page_source, "html.parser") | |
# Extract Distance |
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 flask import Flask, render_template, request, redirect | |
app = Flask(__name__) | |
# Home Page | |
@app.route('/') | |
def index(): | |
return render_template('index.html') | |
# Distance Page |
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
DATE FORMAT | ORDER_NUMBER | SKU | PCS | BRAND | |
---|---|---|---|---|---|
2018-12-10 | 3737303 | 448502 | 1 | Lancome | |
2018-12-10 | 3737303 | 307110 | 1 | Lauder | |
2018-12-10 | 3743178 | 444803 | 1 | Marie Dalgar Co | |
2018-12-01 | 3752413 | 292713 | 1 | Givenchy | |
2018-12-01 | 3752414 | 216152 | 1 | Shiseido | |
2018-12-01 | 3752416 | 401707 | 1 | Marie Dalgar Co | |
2018-12-01 | 3752417 | 347741 | 1 | Guerlain | |
2018-12-01 | 3752418 | 441223 | 1 | Givenchy | |
2018-12-01 | 3752422 | 458573 | 1 | Esthederm |
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
{ | |
"nodes": [ | |
{ | |
"name": "Myriel", | |
"group": 1 | |
}, | |
{ | |
"name": "Napoleon", | |
"group": 1 | |
} |
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 order_brand(PATH_IN): | |
''' List of all brands in each order''' | |
# Import DataFrame | |
df_rec = pd.read_excel(PATH_IN) | |
# Listing Unique Brands | |
df_ordbr = pd.DataFrame(df_rec.groupby(['ORDER_NUMBER'])['BRAND'].unique()) | |
df_ordbr.columns = ['list_brand'] | |
# source = list brands |
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 create_links(df_rec, df_ordbr, list_brand): | |
''' Create links dataframe ''' | |
# Unique brands per order | |
df_source = pd.DataFrame(df_rec.groupby(['ORDER_NUMBER'])['BRAND'].unique()) | |
df_source.columns = ['list_brand'] | |
list_source, list_target, list_value = [], [], [] | |
for br1 in list_brand: | |
for br2 in list_brand: |
OlderNewer