Пример #1
0
 def __init__(self, affiliate, url, merchant_name, merchant_id):
     self.affiliate = affiliate
     self.url = url
     self.merchant_name = merchant_name
     self.merchant_id = merchant_id
     self.limit = 300
     self.logger = logger.get_logger('transactions', affiliate)
Пример #2
0
 def __init__(self):
     self.affiliate = 'admitad'
     self.url = 'https://api.admitad.com/'
     self.client_id = '2877d6947b4195fdb300401a83a96b'
     self.client_secret = '7989ae29e1850a6891a6d22b5e8f7f'
     self.scope = 'statistics'
     self.logger = logger.get_logger('transactions', self.affiliate)
Пример #3
0
 def __init__(self):
     self.affiliate = 'ATVN'
     self.url = 'https://api.accesstrade.vn/'
     self.api_version = 'v1'
     self.access_key = 't4iIdd7-c3TzfaYG7c41SlinVkvjqQWz'
     self.limit = 100
     self.logger = logger.get_logger('transactions', self.affiliate)
Пример #4
0
 def __init__(self,
              affiliate,
              network_id,
              api_key,
              merchant_name=None,
              merchant_id=None,
              currency=None,
              use_network_api=False):
     self.affiliate = affiliate
     self.url = 'https://api.hasoffers.com/Apiv3/json'
     self.network_id = network_id
     self.api_key = api_key
     self.merchant_name = merchant_name
     self.merchant_id = merchant_id
     self.currency = currency
     self.use_network_api = use_network_api
     self.logger = logger.get_logger('transactions', affiliate)
Пример #5
0
    def __init__(self, affiliate, url, username, password):
        self.affiliate = affiliate
        self.url = url
        self.username = username
        self.password = password
        self.logger = logger.get_logger('transactions', affiliate)

        self.countries = {
            1637: 'SG',
            2345: 'SG',  # quirk SG
            948: 'SG',  # SG SG
            1638: 'TH',
            1641: 'MY',
            1621: 'MY',  # old MY
            1642: 'ID',
            1624: 'ID',  # quirk ID
            1643: 'VN',
            1644: 'PH',
            1645: 'HK',
        }
Пример #6
0
 def __init__(self):
     self.affiliate = 'involveasia'
     self.url = 'https://api.involve.asia/api/'
     self.api_key = 'general'
     self.api_secret = 'ieusMm3Im0CKsa6tvpkpu890E4L+f1dKIeLj9hETn7Y='
     self.logger = logger.get_logger('transactions', self.affiliate)
Пример #7
0
import os

import downloader
from common.modules import parse, calculation, logger

reload(sys)
sys.setdefaultencoding("UTF-8")

argparser = argparse.ArgumentParser(add_help=True)
argparser.add_argument('month',
                       type=str,
                       help='Year and month in format: YYYY-MM')
argparser.add_argument('affiliate', type=str, help='Affiliate or all')
argparser.add_argument('type', type=str, help='transactions or performance')

LOGGER = logger.get_logger('transactions', 'download')


def main():
    args = argparser.parse_args()
    LOGGER.info('Process Start', {
        'affiliate': args.affiliate,
        'month': args.month,
        'type': args.type
    })

    # 0. calculate time frame
    (year, month) = map(int, args.month.split("-"))
    start_date = datetime.date(year, month, 1)
    end_date = datetime.date(year, month, calendar.monthrange(year, month)[1])
Пример #8
0
# Imagetyperz captcha API
# ------------------------------

import sys

from imagetypersapi import ImageTypersAPI
from PIL import Image
from common.modules import logger

CAPTCHA_USERNAME = '******'
CAPTCHA_PASSWORD = '******'
LOGGER = logger.get_logger('transactions', 'captcha_resolver')


# solve captcha
def get_captcha_text(driver, screenshot_filename, captcha_filename):
    LOGGER.info("Processing captcha...")

    element = driver.find_element_by_id('vcode')  # get it again here
    size = element.size
    driver.execute_script(
        "document.getElementById('vcode').style.position = 'fixed'")
    driver.execute_script("document.getElementById('vcode').style.left = '0'")
    driver.execute_script("document.getElementById('vcode').style.top = '0'")

    driver.save_screenshot(
        screenshot_filename)  # saves screenshot of entire page
    image = Image.open(
        screenshot_filename)  # uses PIL library to open image in memory

    window_size = driver.get_window_size()
Пример #9
0
import datetime
import hashlib
import pandas
import re

from common.modules import parse_constants, logger

LOGGER = logger.get_logger('transactions', 'parser_module')


def parse_datetime(value, format="%Y-%m-%d %H:%M:%S"):
    dt = datetime.datetime.strptime(value, format)
    return (dt - datetime.datetime(1970, 1, 1)).total_seconds()


def get_date_from_timestamp(timestamp):
    dt = datetime.datetime.utcfromtimestamp(timestamp)
    return (dt.strftime("%Y-%m-%d"), dt.strftime("%m"), dt.strftime("%Y"),
            str(dt.isocalendar()[1]).zfill(2), dt.strftime("%H:%M:%S"))


def parse_sql_datetime(value):
    if pandas.notnull(value):
        d = datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S')
        return datetime.datetime.strftime(d, '%Y-%m-%d %H:%M:%S')

    return pandas.np.nan


def get_datetime_from_timestamp(timestamp, output_format="%Y-%m-%d %H:%M:%S"):
    return datetime.datetime.utcfromtimestamp(timestamp).strftime(
Пример #10
0
#!/usr/bin/python

import argparse
import calendar
import datetime
import sys
import json
import os

import downloader
from affiliates.ipricegroup import IpriceGroup
from common.modules import parse, log, logger

LOGGER = logger.get_logger('transactions', 'sync')

reload(sys)
sys.setdefaultencoding("UTF-8")

argparser = argparse.ArgumentParser(add_help=True)
argparser.add_argument('month', type=str, help='Year and month')
argparser.add_argument('affiliate', type=str, help='Affiliate or all')
argparser.add_argument('--dry_run', type=str, help='True or False')
argparser.add_argument('--testing', type=str, help='True or False')


def main(argv):
    args = argparser.parse_args()
    LOGGER.info('Sync Process Starts', {
        'month': args.month,
        'affiliate': args.affiliate
    })
Пример #11
0
import time
import signal

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from threading import Thread
from common.modules import logger

TIMEOUT = 120
TMP_DIR = tempfile.mkdtemp()
MAX_RUN_TIME = 300
finished = False
LOGGER = logger.get_logger('transactions', 'browser_modules')


def setup_driver():
    profile = FirefoxProfile()
    profile.set_preference("browser.helperApps.neverAsk.saveToDisk",
                           "text/plain,application/csv,application/download,application/octet-stream,text/csv,"
                           "application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
    profile.set_preference("browser.download.folderList", 2)
    profile.set_preference("browser.download.dir", TMP_DIR)

    driver = webdriver.Firefox(firefox_profile=profile)

    thread = Thread(target=kill_driver, args=(driver.service.process.pid,))
    thread.start()