From 4c505d4923c0a9bd7be9123805daa962ec8e5598 Mon Sep 17 00:00:00 2001 From: David Wicker Date: Sun, 6 Dec 2020 20:50:35 +0100 Subject: [PATCH] v2.1.12 --- instaclient/client/instaclient.py | 19 ++++++++++++++----- instaclient/client/paths.py | 1 + setup.py | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/instaclient/client/instaclient.py b/instaclient/client/instaclient.py index 68868c9..e410447 100644 --- a/instaclient/client/instaclient.py +++ b/instaclient/client/instaclient.py @@ -1059,10 +1059,19 @@ def __dismiss_dialogue(self, wait_time:float=2.5): def __press_button(self, button): - button.click() - time.sleep(randrange(0,2)) - self.__detect_restriction() - return True + try: + button.click() + time.sleep(randrange(0,2)) + self.__detect_restriction() + return True + except: + x = self.__find_element(EC.presence_of_element_located((By.XPATH, Paths.X)), wait_time=3) + x.click() + time.sleep(1) + button.click() + time.sleep(randrange(0,2)) + self.__detect_restriction() + return True def __detect_restriction(self): @@ -1104,7 +1113,7 @@ def __init_driver(self, login=False, retries=0, func=None): chrome_options = webdriver.ChromeOptions() chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN") chrome_options.add_argument('--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1') - chrome_options.add_argument("--window-size=343,915") + chrome_options.add_argument("--window-size=414,896") chrome_options.add_argument("--headless") chrome_options.add_argument("--disable-dev-shm-usage") chrome_options.add_argument("--no-sandbox") diff --git a/instaclient/client/paths.py b/instaclient/client/paths.py index 85b6123..5911597 100644 --- a/instaclient/client/paths.py +++ b/instaclient/client/paths.py @@ -34,6 +34,7 @@ class Paths: # Like Feed Posts LIKE_BTN = '' # GENERAL + X = '//div[@class="_7UhW9 xLCgt MMzan KV-D4 uL8Hv "]' COOKIES_LINK = '//a[contains(@heref, "cookies") or contains(text(), "Cookie")]' ACCEPT_COOKIES = '//button[@class="aOOlW bIiDR "]' SETTINGS_BTN = '//button[@class="Q46SR"]' diff --git a/setup.py b/setup.py index a3750fb..70d3276 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( name = 'instaclient', # How you named your package folder (MyLib) packages = find_packages(exclude=['tests, drivers']), # Chose the same as "name" - version = '2.1.11', # Start with a small number and increase it with every change you make + version = '2.1.12', # Start with a small number and increase it with every change you make license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository description = 'Instagram client built with Python 3.8 and the Selenium package.', long_description=README, @@ -19,7 +19,7 @@ author = 'David Wicker', # Type in your name author_email = 'davidwickerhf@gmail.com', # Type in your E-Mail url = 'https://github.com/wickerdevs/py-instaclient', # Provide either the link to your github or to your website - download_url = 'https://github.com/wickerdevs/py-instaclient/archive/v2.1.11.tar.gz', # I explain this later on + download_url = 'https://github.com/wickerdevs/py-instaclient/archive/v2.1.12.tar.gz', # I explain this later on keywords = ['INSTAGRAM', 'BOT', 'INSTAGRAM BOT', 'INSTAGRAM CLIENT'], # Keywords that define your package best install_requires=[ # I get to this in a second 'selenium',