def __init__(self):
        from connection import Connect

        self.__url = 'https://hidester.com/proxydata/php/data.php?mykey=data&offset=0&limit=1500&orderBy=latest_check&' \
                     'sortOrder=DESC&country=ALBANIA,ALGERIA,ANDORRA,ANGOLA,ARGENTINA,ARMENIA,AUSTRALIA,AUSTRIA,' \
                     'BANGLADESH,BELARUS,BELGIUM,BOLIVIA,CAMBODIA,BULGARIA,BRAZIL,CAMEROON,CHILE,CANADA,COLOMBIA,' \
                     'CROATIA,CZECH%20REPUBLIC,ECUADOR,EGYPT,ESTONIA,FRANCE,FINLAND,GEORGIA,GERMANY,GREECE,GUATEMALA,' \
                     'HONDURAS,HUNGARY,INDONESIA,ISRAEL,ITALY,JAPAN,KAZAKHSTAN,LEBANON,MACEDONIA,MALAYSIA,' \
                     'MALDIVES,MALI,MEXICO,MONTENEGRO,MYANMAR,NEPAL,NETHERLANDS,NEW%20ZEALAND,NIGERIA,NORWAY,PARAGUAY,' \
                     'PANAMA,PERU,PHILIPPINES,POLAND,ROMANIA,RUSSIAN%20FEDERATION,SATELLITE%20PROVIDER,SERBIA,SINGAPORE,' \
                     'SOUTH%20AFRICA,SPAIN,SWEDEN,TAIWAN,THAILAND,TRINIDAD%20AND%20TOBAGO,SWITZERLAND,TURKEY,UKRAINE' \
                     ',UNITED%20KINGDOM,UNITED%20STATES,VENEZUELA&port=&type=3&anonymity=7&ping=7&gproxy=2'
        import logging
        logging.Logger.manager.emittedNoHandlerWarning = True
        self.scraper = Connect()
class Hidester(object):
    __metaclass__ = ProxyPool

    def __init__(self):
        from connection import Connect

        self.__url = 'https://hidester.com/proxydata/php/data.php?mykey=data&offset=0&limit=1500&orderBy=latest_check&' \
                     'sortOrder=DESC&country=ALBANIA,ALGERIA,ANDORRA,ANGOLA,ARGENTINA,ARMENIA,AUSTRALIA,AUSTRIA,' \
                     'BANGLADESH,BELARUS,BELGIUM,BOLIVIA,CAMBODIA,BULGARIA,BRAZIL,CAMEROON,CHILE,CANADA,COLOMBIA,' \
                     'CROATIA,CZECH%20REPUBLIC,ECUADOR,EGYPT,ESTONIA,FRANCE,FINLAND,GEORGIA,GERMANY,GREECE,GUATEMALA,' \
                     'HONDURAS,HUNGARY,INDONESIA,ISRAEL,ITALY,JAPAN,KAZAKHSTAN,LEBANON,MACEDONIA,MALAYSIA,' \
                     'MALDIVES,MALI,MEXICO,MONTENEGRO,MYANMAR,NEPAL,NETHERLANDS,NEW%20ZEALAND,NIGERIA,NORWAY,PARAGUAY,' \
                     'PANAMA,PERU,PHILIPPINES,POLAND,ROMANIA,RUSSIAN%20FEDERATION,SATELLITE%20PROVIDER,SERBIA,SINGAPORE,' \
                     'SOUTH%20AFRICA,SPAIN,SWEDEN,TAIWAN,THAILAND,TRINIDAD%20AND%20TOBAGO,SWITZERLAND,TURKEY,UKRAINE' \
                     ',UNITED%20KINGDOM,UNITED%20STATES,VENEZUELA&port=&type=3&anonymity=7&ping=7&gproxy=2'
        import logging
        logging.Logger.manager.emittedNoHandlerWarning = True
        self.scraper = Connect()

    def get_proxy_json(self):
        from convert_response import ToJSON
        self.scraper.url = self.__url
        self.scraper.HTTP_mode = HTTPMethods.GET
        return ToJSON(self.scraper.fetch())

    def generate_pool(self):
        proxies = self.get_proxy_json()
        proxy_pool = dict(https=[], http=[])
        for proxy in proxies:
            proxy_pool[proxy['type']].append(
                "%s://%s:%s" % (proxy['type'], proxy['IP'], proxy['PORT']))

        return ProxyDB().prune_bad_proxies(proxy_pool)
Пример #3
0
    def __load_blocks(self):
        """
			Initialization of main functionality blocks of bot.

		"""
        # TODO: Providing client to main functionality blocks seems not really good ;( "Peredacha clienta"
        self.Settings = Settings(self.SettingsFolder)
        self.Player = Player(self)
        self.Connect = Connect(self)
        self.Command = Command(self)
Пример #4
0
def login():
    try:
        if not check_arguments(['login', 'password'], request.args):
            raise Exception('Bad arguments')

        login = request.args.get('login')
        password = request.args.get('password')

        if db_worker.confirm_data_login(login, password):
            code = "".join(str(uuid4()).split('-'))
            if Connect.find(InfoConnect(login, code)):
                raise Exception("You logged already")

            item = InfoConnect(login, code)
            Connect.add(item)
            return json.dumps({'code': code})

        raise Exception("No such login and password")

    except Exception as e:
        return make_response(str(e), 400, {'olol':'ololol'})
Пример #5
0
def check_connect():
    try:
        if not check_arguments(['login', 'code'], request.args):
            raise Exception("Bad arguments")

        login = request.args.get("login")
        code = request.args.get("code")
        if Connect.find(InfoConnect(login, code)):
            return json.dumps({'ok': 'ok'})

        raise Exception("Access denied")

    except Exception as e:
        return make_response(str(e), 400, {'olol':'ololol'})
Пример #6
0
def logout():
    try:
        if not check_arguments(['login', 'code'], request.args):
            raise Exception("Bad arguments")

        login = request.args.get("login")
        code = request.args.get("code")
        if Connect.remove(login, code):
            return json.dumps({'ok': 'ok'})

        raise Exception("You not logged yet")

    except Exception as e:
        return make_response(str(e), 400, {'olol':'ololol'})
    def __init__(self):
        from connection import Connect

        self.__url = (
            "https://hidester.com/proxydata/php/data.php?mykey=data&offset=0&limit=1500&orderBy=latest_check&"
            "sortOrder=DESC&country=ALBANIA,ALGERIA,ANDORRA,ANGOLA,ARGENTINA,ARMENIA,AUSTRALIA,AUSTRIA,"
            "BANGLADESH,BELARUS,BELGIUM,BOLIVIA,CAMBODIA,BULGARIA,BRAZIL,CAMEROON,CHILE,CANADA,COLOMBIA,"
            "CROATIA,CZECH%20REPUBLIC,ECUADOR,EGYPT,ESTONIA,FRANCE,FINLAND,GEORGIA,GERMANY,GREECE,GUATEMALA,"
            "HONDURAS,HUNGARY,INDONESIA,ISRAEL,ITALY,JAPAN,KAZAKHSTAN,LEBANON,MACEDONIA,MALAYSIA,"
            "MALDIVES,MALI,MEXICO,MONTENEGRO,MYANMAR,NEPAL,NETHERLANDS,NEW%20ZEALAND,NIGERIA,NORWAY,PARAGUAY,"
            "PANAMA,PERU,PHILIPPINES,POLAND,ROMANIA,RUSSIAN%20FEDERATION,SATELLITE%20PROVIDER,SERBIA,SINGAPORE,"
            "SOUTH%20AFRICA,SPAIN,SWEDEN,TAIWAN,THAILAND,TRINIDAD%20AND%20TOBAGO,SWITZERLAND,TURKEY,UKRAINE"
            ",UNITED%20KINGDOM,UNITED%20STATES,VENEZUELA&port=&type=3&anonymity=7&ping=7&gproxy=2"
        )
        import logging

        logging.Logger.manager.emittedNoHandlerWarning = True
        self.scraper = Connect()
class Hidester(object):
    __metaclass__ = ProxyPool

    def __init__(self):
        from connection import Connect

        self.__url = (
            "https://hidester.com/proxydata/php/data.php?mykey=data&offset=0&limit=1500&orderBy=latest_check&"
            "sortOrder=DESC&country=ALBANIA,ALGERIA,ANDORRA,ANGOLA,ARGENTINA,ARMENIA,AUSTRALIA,AUSTRIA,"
            "BANGLADESH,BELARUS,BELGIUM,BOLIVIA,CAMBODIA,BULGARIA,BRAZIL,CAMEROON,CHILE,CANADA,COLOMBIA,"
            "CROATIA,CZECH%20REPUBLIC,ECUADOR,EGYPT,ESTONIA,FRANCE,FINLAND,GEORGIA,GERMANY,GREECE,GUATEMALA,"
            "HONDURAS,HUNGARY,INDONESIA,ISRAEL,ITALY,JAPAN,KAZAKHSTAN,LEBANON,MACEDONIA,MALAYSIA,"
            "MALDIVES,MALI,MEXICO,MONTENEGRO,MYANMAR,NEPAL,NETHERLANDS,NEW%20ZEALAND,NIGERIA,NORWAY,PARAGUAY,"
            "PANAMA,PERU,PHILIPPINES,POLAND,ROMANIA,RUSSIAN%20FEDERATION,SATELLITE%20PROVIDER,SERBIA,SINGAPORE,"
            "SOUTH%20AFRICA,SPAIN,SWEDEN,TAIWAN,THAILAND,TRINIDAD%20AND%20TOBAGO,SWITZERLAND,TURKEY,UKRAINE"
            ",UNITED%20KINGDOM,UNITED%20STATES,VENEZUELA&port=&type=3&anonymity=7&ping=7&gproxy=2"
        )
        import logging

        logging.Logger.manager.emittedNoHandlerWarning = True
        self.scraper = Connect()

    def get_proxy_json(self):
        from convert_response import ToJSON

        self.scraper.url = self.__url
        self.scraper.HTTP_mode = HTTPMethods.GET
        return ToJSON(self.scraper.fetch())

    def generate_pool(self):
        proxies = self.get_proxy_json()
        proxy_pool = dict(https=[], http=[])
        for proxy in proxies:
            proxy_pool[proxy["type"]].append("%s://%s:%s" % (proxy["type"], proxy["IP"], proxy["PORT"]))

        return ProxyDB().prune_bad_proxies(proxy_pool)
Пример #9
0
 def __init__(self, log="simplescraper.log"):
     from logger import get_logger
     logger = get_logger(log, maxbytes=2147483648)
     Connect.__init__(self, logger)
Пример #10
0
def operations(opcao):
    if opcao == 1:

        cpf = inputCPF()
        cpf_valido = valid_cpf(cpf)

        if cpf_valido == 1:

            nome = inputName()
            nome_valido = nameValidator(nome)

            email = inputEmail()
            email_valido = validate_email(email)

            if nome_valido == 1 and email_valido == 1:
                conn = Connection().getConnection()
                cur = conn.cursor()
                cur.execute(
                    "insert into pessoa (nome, cpf, email, logado) values ('{0}','{1}','{2}','3')"
                    .format(nome, cpf, email))

                conn.commit()
                conn.close()

                mainMenu()

            else:
                mainMenu()

        else:
            mainMenu()

    elif opcao == 2:

        acao_select = int(
            input(
                "O que gostaria de fazer?\n3- Ver tudo\n2- Consultar por CPF\n3- Consultar por email\n4- Sair\n\nDIGITE: "
            ))

        if acao_select == 1:
            conn = Connection().getConnection()
            cur = conn.cursor()
            cur.execute("select * from pessoa where logado = '3'")

            rows = cur.fetchall()

            for row in rows:
                print(row[0], str(row[1]), row[2], row[3])
                conn.close()
                mainMenu()

        elif acao_select == 2:

            cpf = inputCPF()
            cpf_valido = valid_cpf(cpf)

            if cpf_valido == 1:
                conn = Connection().getConnection()
                cur = conn.cursor()
                cur.execute(
                    "select * from pessoa where logado = '3' and cpf = '{0}'".
                    format(cpf))
                rows = cur.fetchall()

            for row in rows:
                print(row[0], str(row[1]), row[2], row[3])

                conn.close()
                mainMenu()

            else:
                mainMenu()

        elif acao_select == 3:

            email = inputEmail()
            email_valido = validate_email(email)

            if email_valido == 1:
                conn = Connection().getConnection()
                cur = conn.cursor()
                cur.execute("select * "
                            "from pessoa "
                            "where logado = '3' "
                            "and email = '{0}'".format(email))

                rows = cur.fetchall()

            for row in rows:
                print(row[0], str(row[1]), row[2], row[3])

                conn.close()
                mainMenu()

            else:
                print("Email não encontrado.")
                mainMenu()

        elif acao_select == 4:
            print("Opção finalizada.")
            mainMenu()

        else:
            print("Opção inválida.")
            mainMenu()

    elif opcao == 3:

        acao_select = int(
            input("\n1- Atualizar nome\n2- Atualizar email\n3- Sair\n\n"))

        if acao_select == 1:

            cpf = inputCPF()
            cpf_valido = valid_cpf(cpf)

            nome = inputName()
            nome_valido = nameValidator(nome)

            if nome_valido == 1:
                conn = Connection().getConnection()

                cur = conn.cursor()
                cur.execute("update pessoa "
                            "set nome = '{0}' "
                            "where cpf = '{1}'".format(nome, cpf))
                conn.commit()
                conn.close()

            else:
                print("Nome inválido. Tente novamente.")

        elif acao_select == 2:

            cpf = inputCPF()
            cpf_valido = valid_cpf(cpf)

            email = inputEmail()
            email_valido = validate_email(email)

            if email_valido == 1:

                conn = Connection().getConnection()

                cur = conn.cursor()
                cur.execute("Update pessoa" " set email = '{0}'".format(email))
                conn.commit()
                conn.close()

            else:
                print("Email inválido.")
                mainMenu()

        elif acao_select == 3:
            mainMenu()

        else:
            print("Opção inválida.")
            mainMenu()

    elif opcao == 4:

        cpf = inputCPF()
        cpf_valido = valid_cpf(cpf)

        if cpf_valido == 1:

            conn = Connect().getConnection()

            cur = conn.cursor()
            cur.execute("update pessoa"
                        " set logado = 0"
                        " where cpf = '{0}'".format(cpf))
            conn.commit()

            conn.close()
            mainMenu()

        else:
            print("CPF inválido. => ", cpf)

    elif opcao == 0:
        print("Exit.")
        exit()

    else:
        print("Opção invalida")
        mainMenu()
Пример #11
0
 def connect(self):
     conn = Connect(self.dsn)
     self.cursor = conn.cur()
Пример #12
0
 def connect(self):
     conn = Connect(self.dsn)
     self.cursor = conn.cur()
from connection import Connect
from preprocess_data import Preprocess_Data

session = Connect()
df = Preprocess_Data()


def table_1():
    query_1 = 'CREATE TABLE IF NOT EXISTS music_history'
    query_1 = query_1 + '(session_id INT,item_session INT, song_title TEXT, artist_name TEXT, song_length FLOAT, PRIMARY KEY(session_id,item_session))'
    session.execute(query_1)
    query_1 = "INSERT INTO music_history(session_id,item_session,song_title,artist_name,song_length)"
    query_1 = query_1 + 'VALUES(%s,%s,%s,%s,%s)'
    len_ = len(df['artist'])
    for i in range(len_):
        session.execute(query_1, (df.iloc[i][8], df.iloc[i][3], df.iloc[i][9],
                                  df.iloc[i][0], df.iloc[i][5]))


def table_2():
    query_2 = 'CREATE TABLE IF NOT EXISTS user_choice'
    query_2 = query_2 + '(user_id INT,item_session INT, session_id INT, first_name TEXT, last_name TEXT, artist_name TEXT,song_name TEXT, PRIMARY KEY(user_id,session_id,item_session))'
    session.execute(query_2)
    query_2 = "INSERT INTO user_choice(user_id,item_session,session_id,first_name,last_name,artist_name,song_name)"
    query_2 = query_2 + 'VALUES(%s,%s,%s,%s,%s,%s,%s)'
    len_ = len(df['artist'])
    for i in range(len_):
        session.execute(
            query_2,
            (df.iloc[i][10], df.iloc[i][3], df.iloc[i][8], df.iloc[i][1],
             df.iloc[i][4], df.iloc[i][0], df.iloc[i][9]))
Пример #14
0
        if Connect.remove(login, code):
            return json.dumps({'ok': 'ok'})

        raise Exception("You not logged yet")

    except Exception as e:
        return make_response(str(e), 400, {'olol':'ololol'})


@app.route("/check_connect")
def check_connect():
    try:
        if not check_arguments(['login', 'code'], request.args):
            raise Exception("Bad arguments")

        login = request.args.get("login")
        code = request.args.get("code")
        if Connect.find(InfoConnect(login, code)):
            return json.dumps({'ok': 'ok'})

        raise Exception("Access denied")

    except Exception as e:
        return make_response(str(e), 400, {'olol':'ololol'})

if __name__ == "__main__":
    db_worker = DBWorker()
    Connect = Connect()
    app.run(debug=True, port=65011)

Пример #15
0
from create_table import table_1,table_2,table_3
from connection import Connect
session = Connect()

print('**********Result - 1 *************')

rows=session.execute('SELECT artist_name,song_title,song_length FROM music_history WHERE session_id = 338 AND item_session = 4')
for row in rows:
    print(row)

print()

print('*************** Result - 2 *******************')
rows=session.execute('SELECT artist_name,song_name,first_name,last_name FROM user_choice WHERE user_id = 10 AND session_id = 182')
for row in rows:
    print(row)
    
print()

print('*************** Result - 3 ********************')
rows=session.execute("SELECT artist_name,song_title,song_length,first_name,last_name FROM music_history_app WHERE song_title='All Hands Against His Own'")
for row in rows:
    print(row)
Пример #16
0
from connection import Connect
from selectQuery import Select
from comparisonOperators import __eq, __lt
from logicalOperators import __and
import os


connection = Connect(
    "localhost",
    "root",
    os.environ.get('MYSQL_PASSWORD'),
    "form"
    )

select_result = Select(
    connection=connection,
    columns=["user_id", "first_name", "last_name"],
    tables=["user_details"]
    )
condition = __and(__lt('user_id', 6), __eq('first_name', 'David'))
print(select_result.condition(condition).execute_query())