Example #1
0
    def like(self, amount=1, ratio='100%', sleep=1):

        ratio = float(ratio.split('%')[0]) / 100

        if self.isLoggedIn():
            helper = GeomatchHelper(browser=self.browser)
            loadingbar = LoadingBar(amount, "likes")
            amount_liked = 0
            # handle one time up front, from then on check after every action instead of before
            self.handlePotentialPopups()
            while amount_liked < amount:
                if random.random() <= ratio:
                    helper.like()
                    amount_liked += 1

                    # update for stats after session ended
                    self.session_data['like'] += 1

                    # update loadingbar display
                    loadingbar.updateLoadingBar(amount_liked)

                else:
                    helper.dislike()

                    # update for stats after session ended
                    self.session_data['dislike'] += 1

                self.handlePotentialPopups()
                time.sleep(sleep)
Example #2
0
    def getMessagedMatches(self):
        # Make sure we're in the 'messaged matches' tab
        try:
            xpath = '//*[@id="messages-tab"]'
            # wait for element to appear
            WebDriverWait(self.browser, self.delay).until(EC.presence_of_element_located((By.XPATH, xpath)))

            messagesTab = self.browser.find_element_by_xpath(xpath)
            messagesTab.click()
            time.sleep(1)

        except TimeoutException:
            print("match tab could not be found, trying again")
            self.browser.get(self.HOME_URL)
            time.sleep(1)
            return self.getMessagedMatches()
        except Exception as e:
            print("An unhandled exception occured in getNewMatches:")
            print(e)

        matches = []

        # Start scraping the chatted matches
        try:
            class_name = 'messageList'

            # wait for element to appear
            WebDriverWait(self.browser, self.delay).until(EC.presence_of_element_located(
                (By.CLASS_NAME, class_name)))

            div = self.browser.find_element_by_class_name(class_name)

            list_refs = div.find_elements_by_class_name('messageListItem')

            chatids = []

            for index in range(len(list_refs)):
                ref = list_refs[index].get_attribute('href')
                chatids.append(ref.split('/')[-1])

            print("\nGetting interacted-with, MESSAGED MATCHES")
            loadingbar = LoadingBar(len(chatids), "interacted-with-matches")
            for index, chatid in enumerate(chatids):
                matches.append(self.getMatch(chatid))
                loadingbar.updateLoadingBar(index)

            print("\n")
        except NoSuchElementException:
            pass

        except TimeoutException:
            pass

        return matches
Example #3
0
    def superlike(self, amount=1):
        if self.isLoggedIn():
            helper = GeomatchHelper(browser=self.browser)
            loadingbar = LoadingBar(amount, "superlikes")
            for index in range(amount):
                self.handlePotentialPopups()
                helper.superlike()
                # update for stats after session ended
                self.session_data['dislike'] += 1

                # update loadingbar display
                loadingbar.updateLoadingBar(index)
Example #4
0
    def get_messaged_matches(self, amount, quickload):
        matches = []
        used_chatids = []
        new_chatids = self.get_chat_ids(new=False, messaged=True)

        while True:

            if len(matches) >= amount:
                break

            # shorten the list so doesn't fetch ALL matches but just the amount it needs
            diff = len(matches) + len(new_chatids) - amount
            if diff > 0:
                del new_chatids[-diff:]

            print("\nGetting interacted-with, MESSAGED MATCHES")
            loadingbar = LoadingBar(len(new_chatids),
                                    "interacted-with-matches")
            for index, chatid in enumerate(new_chatids):
                matches.append(self.get_match(chatid, quickload))
                loadingbar.update_loading(index)
            print("\n")

            # scroll down to get more chatids
            xpath = '//div[@class="messageList"]'
            tab = self.browser.find_element_by_xpath(xpath)
            self.browser.execute_script(
                'arguments[0].scrollTop = arguments[0].scrollHeight;', tab)
            time.sleep(4)

            new_chatids = self.get_chat_ids(new=False, messaged=True)
            copied = new_chatids.copy()
            for index in range(len(copied)):
                if copied[index] in used_chatids:
                    new_chatids.remove(copied[index])
                else:
                    used_chatids.append(new_chatids[index])

            # no new matches are found, MAX LIMIT
            if len(new_chatids) == 0:
                break

        return matches
Example #5
0
    def get_new_matches(self, amount, quickload):
        matches = []
        used_chatids = []
        iteration = 0
        while True:
            iteration += 1
            if len(matches) >= amount:
                break

            new_chatids = self.get_chat_ids(new=True, messaged=False)
            copied = new_chatids.copy()
            for index in range(len(copied)):
                chatid = copied[index]
                if chatid in used_chatids:
                    new_chatids.remove(chatid)
                else:
                    used_chatids.append(chatid)

            # no new matches are found, MAX LIMIT
            if len(new_chatids) == 0:
                break

            # shorten the list so doesn't fetch ALL matches but just the amount it needs
            diff = len(matches) + len(new_chatids) - amount

            if diff > 0:
                del new_chatids[-diff:]

            print(f"\nGetting not-interacted-with, NEW MATCHES, part {iteration}")
            loadingbar = LoadingBar(len(new_chatids), "new matches")
            for index, chatid in enumerate(new_chatids):
                matches.append(self.get_match(chatid, quickload))
                loadingbar.update_loading(index)
            print("\n")

            # scroll down to get more chatids
            xpath = '//div[@role="tabpanel"]'
            tab = self.browser.find_element_by_xpath(xpath)
            self.browser.execute_script('arguments[0].scrollTop = arguments[0].scrollHeight;', tab)
            time.sleep(4)

        return matches