예제 #1
0
파일: bot.py 프로젝트: bernadsatriani/bot
    def __init__(self,
                 username=None,
                 password=None,
                 nogui=False,
                 selenium_local_session=True,
                 use_firefox=False,
                 page_delay=25,
                 show_logs=True,
                 headless_browser=False,
                 proxy_address=None,
                 proxy_chrome_extension=None,
                 proxy_port=0,
                 bypass_suspicious_attempt=True,
                 multi_logs=False,
                 env=json.loads(os.environ.get('ENV', '{}'))):

        p_address: str = env.get("proxy_address", proxy_address)
        p_port: str = env.get("proxy_port", proxy_port)

        if p_address and p_port:
            proxy_login: str = env.get("proxy_login")
            proxy_password: str = env.get("proxy_password")
            if proxy_login and proxy_password:
                from proxy_extension import create_proxy_extension
                proxy = proxy_login + ':' + proxy_password + '@' + p_address + ':' + p_port
                proxy_chrome_extension = create_proxy_extension(proxy)

                proxy_address = None
                proxy_port = None
            else:
                proxy_address = p_address
                proxy_port = p_port

        super().__init__(username=username,
                         password=password,
                         nogui=nogui,
                         selenium_local_session=selenium_local_session,
                         use_firefox=use_firefox,
                         page_delay=page_delay,
                         show_logs=show_logs,
                         headless_browser=headless_browser,
                         proxy_address=proxy_address,
                         proxy_chrome_extension=proxy_chrome_extension,
                         proxy_port=proxy_port,
                         bypass_suspicious_attempt=bypass_suspicious_attempt,
                         multi_logs=multi_logs)
        self.settings = env
        self.end_time = parse_datetime_prefix(
            str(
                env.get("end_time",
                        datetime.datetime.now() +
                        datetime.timedelta(hours=1))), '%Y-%m-%d %H:%M:%S')
예제 #2
0
    def __init__(self,
                 username=None,
                 password=None,
                 nogui=False,
                 selenium_local_session=True,
                 use_firefox=False,
                 page_delay=25,
                 show_logs=True,
                 headless_browser=False,
                 proxy_address=None,
                 proxy_chrome_extension=None,
                 proxy_port=None,
                 multi_logs=False,
                 env=load_env(),
                 proxy_address_port=None,
                 bypass_suspicious_attempt=False,
                 bypass_with_mobile=False,
                 disable_image_load=True
                 ):

        if proxy_address_port:
            p_address = proxy_address_port.split(":")[0]
            p_port = int(proxy_address_port.split(":")[1])
        else:
            p_address = proxy_address
            p_port: int = proxy_port

        if p_address and p_port:
            proxy_login: str = env.get("proxy_login")
            proxy_password: str = env.get("proxy_password")
            if proxy_login and proxy_password:
                from proxy_extension import create_proxy_extension
                proxy = proxy_login + ':' + proxy_password + '@' + p_address + ':' + p_port
                proxy_chrome_extension = create_proxy_extension(proxy)

                proxy_address = None
                proxy_port = None
            else:
                proxy_address = p_address
                proxy_port = p_port

        self.settings = clean_settings(env)
        self.end_time = parse_datetime_prefix(
            str(env.get("end_time", datetime.datetime.now() + datetime.timedelta(hours=1))), '%Y-%m-%d %H:%M:%S')
        os.environ["INSTA_USER"] = username or os.environ.get('INSTA_USER')
        os.environ["INSTA_PW"] = password or os.environ.get('INSTA_PW')

        print(
            "super().init(username=%s, password=%s, nogui=%s, selenium_local_session=%s, use_firefox=%s, page_delay=%s, show_logs=%s, headless_browser=%s, proxy_address=%s, proxy_chrome_extension=%s, proxy_port=%s, disable_image_load=%s, multi_logs=%s)"
            % (
                os.environ["INSTA_USER"],
                os.environ["INSTA_PW"],
                nogui,
                selenium_local_session,
                use_firefox,
                page_delay,
                show_logs,
                headless_browser,
                proxy_address,
                proxy_chrome_extension,
                proxy_port,
                True,
                multi_logs))
        super().__init__(username=os.environ["INSTA_USER"],
                         password=os.environ["INSTA_PW"],
                         nogui=nogui,
                         selenium_local_session=selenium_local_session,
                         use_firefox=use_firefox,
                         page_delay=page_delay,
                         show_logs=show_logs,
                         headless_browser=headless_browser,
                         proxy_address=proxy_address,
                         proxy_chrome_extension=proxy_chrome_extension,
                         proxy_port=proxy_port,
                         disable_image_load=disable_image_load,
                         bypass_suspicious_attempt=env.get("bypass_suspicious_attempt",
                                                           bypass_suspicious_attempt) == "True",
                         bypass_with_mobile=env.get("bypass_with_mobile", bypass_with_mobile) == "True",
                         multi_logs=multi_logs)
        self.logger.info("Settings: %s" % self.settings)
예제 #3
0
InstaPy.
"""

# imports
import time
import logging
from instapy import InstaPy
from instapy.util import smart_run
from proxy_extension import create_proxy_extension

# login credentials
insta_username = '******'
insta_password = '******'

proxy = 'lum-customer-hl_648f8412-zone-static-ip-185.217.61.22:[email protected]:22225'
proxy_chrome_extension = create_proxy_extension(proxy)

# get an InstaPy session!
# set headless_browser=True to run InstaPy in the background
session = InstaPy(username=insta_username,
                  password=insta_password,
                  proxy_chrome_extension=proxy_chrome_extension,
                  nogui=False,
                  headless_browser=True)

with smart_run(session):
    while True:
        cur = time.time()

        time.sleep(10)
        session.like_by_tags(['love'], amount=1, interact=False)