Exemple #1
0
 def __init__(self):
     self.account = ''
     self.driver = Driver()
     self.streamer = Streamer()
     self.stream_table = 'stream'
     self.accounts_table = 'accounts'
     self.limit = self.driver.limit
Exemple #2
0
    def __init__(self, bl_number):
        self.driver = Driver()
        dummy_url = '/error404'
        self.bl_number = bl_number  # BL format : 6194326880
        self.driver.get_page(COSCOURL + dummy_url)
        self.driver.add_cookies()
        self.driver.get_page(COSCOURL + '/cargoTracking')

        # Locates search box and inputs BL number
        search_element = self.driver.find_xpath_element(
            '//*[@id="wrap"]/input')
        search_element.send_keys(bl_number)

        # Locates search button and clicks
        search_xpath = '/html/body/div[1]/div[4]/div[1]/div/div[1]/div/div[2]/form/div/div[2]/button'
        search_button = self.driver.find_xpath_element(search_xpath)
        search_button.click()

        # Locates table containing majority of information
        main_info_table = self.driver.find_class_element('ivu-c-detailPart')
        main_info_text = main_info_table.text
        raw_info = main_info_text.replace(' ', '')
        self.main_info = raw_info.split('\n')

        # Locates table containing secondary information
        secondary_xpath = '/html/body/div[1]/div[4]/div[1]/div/div[2]/div/div/div[2]/div[1]/div[2]/div'
        secondary_table = self.driver.find_xpath_element(secondary_xpath)
        secondary_info_text = secondary_table.text
        self.secondary_info = secondary_info_text.split('\n')
Exemple #3
0
def pull(variable):
    driver = Driver()
    driver.connect(mode='heroku')
    query = 'select row_to_json({0}) from {0}'.format(variable)
    result = driver.pull(query)
    result = [x for t in result for x in t]
    output_dct = {'content': result}
    return jsonify(output_dct)
Exemple #4
0
 def update(self):
     self.reddit = self.auth()
     driver = Driver()
     subs = driver.pull('select * from {0}'.format(self.subreddits_table))
     self.subreddits_names = [x for t in subs for x in t]
     self.subreddits_names = [
         x for x in self.subreddits_names if isinstance(x, str)
     ]
Exemple #5
0
def overwrite(variable):
    driver = Driver()
    driver.connect(mode='heroku')
    input_json = request.get_json(force=True)
    input_json['table'] = variable
    restart_query = render_template('restart.sql.jinja2', **input_json)
    insert_query = render_template('jsondump.sql.jinja2', **input_json)
    driver.push(restart_query)
    driver.push(insert_query)
Exemple #6
0
    def __init__(self, bl_number):
        # Instantiates Driver class and opens url in headless browser
        self.driver = Driver()
        self.driver.get_page(MSCURL)
        self.driver.add_cookies({
            'name': 'newsletter-signup-cookie',
            'value': 'temp-hidden'
        })
        self.bl_number = bl_number

        # Locates search box and inputs BL number
        element = self.driver.find_id_element(
            "ctl00_ctl00_plcMain_plcMain_TrackSearch_txtBolSearch_TextField")
        element.send_keys('MEDUQ' + self.bl_number)  # BL Format: 1312550

        # Locates search button and clicks
        search_button_xpath = '//*[@id="ctl00_ctl00_plcMain_plcMain_TrackSearch_pnlTrackSearchForm"]/div/div[2]'
        search = self.driver.find_xpath_element(search_button_xpath)
        search.click()
Exemple #7
0
import time, random
from datetime import datetime

from config import Config
from utils import Utils, Driver
from checks.all_imports import *

Utils.self_check()
Utils.log_restart()
lands = Utils.get_lands()

if not Utils.cookies_exist():
    driver = Driver(images=True, headless=False)
    driver.cookie_saver()
    driver.stop()

for land in lands:

    runner = Driver()
    runner.land = land[0]
    runner.track_url = land[1]

    if runner.track_url == '0':
        runner.link = '%s?fbpixel=%s' % (runner.land, runner.FBPIXEL)
    else:
        runner.link = '%s?track_url=%s&fbpixel=%s' % (
            runner.land, runner.track_url, runner.FBPIXEL)
    if 'leadrocktest.com' in runner.link:
        runner.link = runner.link.replace(
            '://', '://%s:%s@' % (runner.SERVER_LOGIN, runner.SERVER_PASS))
Exemple #8
0
def push():
    driver = Driver()
    driver.connect(mode='heroku')
    input_json = request.get_json(force=True)
    query = render_template('jsondump.sql.jinja2', **input_json)
    driver.push(query)
Exemple #9
0
 def setup_class(self):
     self.driver = Driver().get_driver()
     self.login = Work()
Exemple #10
0
        try:
            for post in self.streamer:
                idx += 1
                post_type = self.get_type(post)
                copies = self.driver.pull_var(
                    select_query.format(self.stream_table), (post.id, ))
                copies = [x for t in copies for x in t]
                if not any(copies):
                    self.driver.push_var(
                        insert_query.format(self.stream_table),
                        (post.id, post_type))
                if idx >= self.limit:
                    self.driver.check(self.stream_table)
                    idx = 1
        except:
            self.auth()
            self.build()
            self.run()

    def __call__(self):
        self.auth()
        self.build()
        self.run()


if __name__ == '__main__':
    driver = Driver()
    driver.initialize()
    man = Manager()
    man()
Exemple #11
0
 def __init__(self,*args,**kwargs):
     self.reddit = ''
     self.account = ''
     self.driver = Driver()
     self.bot = ArchiveBot()
     self.error = "There was an error processing your request."