Beispiel #1
0
    def follower_looper(self):
        print("starting follower_looper()")

        gls.log_file_writer()
        try:
            # this loop sends dms to everyone I follow
            for i in range(len(self.follower_id_list)):
                gls.api.send_direct_message(
                    self.follower_id_list[i],
                    f'{self.custom_msg_list[randint(0, len(self.custom_msg_list) - 1)]} {self.screen_name_list[i]} :)!'
                )

                gls.sleep_time()

                # del (self.screen_name_list[i])
                # del (self.follower_id_list[i])
                #
                # print(f'index - {i} len - {len(self.screen_name_list)}')
                #
                # if i == gls.random_num or len(self.screen_name_list) < gls.random_num:
                #     break

        except tweepy.TweepError as e:
            logging.error('Error occurred ' + str(e))

        except Exception as e:
            logging.error('Error occurred ' + str(e))

        finally:
            pass

        print(
            "follower_looper() has terminated after 5 iterations and deletions "
        )
        return len(self.screen_name_list)
Beispiel #2
0
def tweet_list_downloader(downloaded_tweets_csv, hashtag):
    gls.log_file_writer()

    try:
        tweets_csv = open(downloaded_tweets_csv, gls.write)
        csv_writer = csv.writer(tweets_csv)
        print("hashtag downloading on: ", hashtag)
        for single_tweet in tweepy.Cursor(api.search, q=hashtag, rpp=1200, lang="en", since="2018-08-17").items(100000):
            print(single_tweet.id_str)
            single_tweet.favorite()
            gls.sleep_time()
            single_tweet.retweet()

            print(single_tweet.author, single_tweet.created_at, single_tweet.text)

            csv_writer.writerow([str(single_tweet.id_str)+'x', single_tweet.text])

            print("row (hopefully) written into csv")

    except IOError as e2:
        logging.error('Error occurred ' + str(e2))

    except tweepy.TweepError as e3:
        logging.error('Error occurred ' + str(e3))

    except Exception as x4:
        logging.error('Error occurred ' + str(x4))

    finally:
        print("end of like and retweet cycle")
Beispiel #3
0
def custom_replier():
    gls.log_file_writer()

    try:
        print("replying to custom mentions...")
        last_seen_id = get_last_seen_id(gls.value_holder_file)

        mentions = api.mentions_timeline(last_seen_id, tweet_mode='extended')
        # print(mentions[0].__dict__.keys())  # converts list into dict and extracts all the keys
        #
        # print(mentions[0].text)
        # 1163451084704079873 for testing

        for single_mention in reversed(mentions):
            print(f"mention id {single_mention.id} - mention full text {single_mention.full_text}")
            last_seen_id = single_mention.id
            save_last_seen_id(last_seen_id, gls.value_holder_file)

            api.update_status(
                "merry christmas and happy new year",
                single_mention.id)

            gls.sleep_time()

    except tweepy.TweepError as ess:
        logging.error('Error occurred ' + str(ess))

    except Exception as eww:
        logging.error('Error occurred ' + str(eww))

    finally:
        pass

    print("custom_replier() has terminated ")
Beispiel #4
0
    def wp_login(self, site, email, password):
        wp_login_url = f'{site}/wp-login.php?checkemail=confirm'
        wp_email_xpath = '//*[@id="user_login"]'
        wp_password_xpath = '//*[@id="user_pass"]'
        wp_login_xpath = '//*[@id="wp-submit"]'
        wp_email = email
        wp_password = password

        try:

            self.driver.get(wp_login_url)
            gls.sleep_time()
            self.driver.find_element_by_xpath(wp_email_xpath).send_keys(
                wp_email)
            gls.sleep_time()
            self.driver.find_element_by_xpath(wp_password_xpath).send_keys(
                wp_password)
            gls.sleep_time()
            continue_btn = self.driver.find_element_by_xpath(wp_login_xpath)
            gls.sleep_time()
            continue_btn.click()

        except Exception as ex:
            print("wp login error at ", ex)
            print(traceback.format_exc())
Beispiel #5
0
    def wp_login(self):
        wp_login_url = 'https://wordpress.com/wp-login.php?checkemail=confirm'
        wp_email_xpath = '//*[@id="user_login"]'
        wp_password_xpath = '//*[@id="user_pass"]'
        wp_login_xpath = '//*[@id="wp-submit"]'
        wp_email = "*****@*****.**"
        wp_password = '******'

        try:
            self.driver.delete_all_cookies()
            self.driver.get(wp_login_url)
            gls.sleep_time()
            self.driver.find_element_by_xpath(wp_email_xpath).send_keys(
                wp_email)
            gls.sleep_time()
            self.driver.find_element_by_xpath(wp_password_xpath).send_keys(
                wp_password)
            gls.sleep_time()
            continue_btn = self.driver.find_element_by_xpath(wp_login_xpath)
            gls.sleep_time()
            continue_btn.click()

        except Exception as ex:
            print("wp login error at ", ex)
            print(traceback.format_exc())
    def tweet_sender(self):
        print("starting tweet_sender()")

        gls.log_file_writer()

        try:
            for i in range(len(self.tweets_list)):
                # the following line sends out the tweets from the list
                gls.api.update_status(
                    f'{self.tweets_list[i]} {gls.random_hashtag()}')

                time_slept = gls.sleep_time()
                #
                # del (self.tweets_list[i])
                #
                # print(f'index - {i} len - {len(self.tweets_list)}')
                #
                # if i == gls.random_num or len(self.tweets_list) < gls.random_num:
                #     break

        except tweepy.TweepError as e:
            logging.error('Error occurred ' + str(e))

        finally:
            pass

        print(
            "follower_looper() has terminated after 5 iterations and deletions "
        )
        return len(self.tweets_list)
Beispiel #7
0
    def single_tweet_replier(self):
        print("starting screen_name_follower()")

        gls.log_file_writer()

        try:
            for i in range(len(self.screen_name_list)):
                gls.api.update_status(
                    status=
                    f"@{self.screen_name_list[i]}  {self.custom_tweet_list[randint(0, len(self.custom_tweet_list) - 1)]}",
                    in_reply_to_status_id=self.tweet_id_list[i][:-1])
                time_slept = gls.sleep_time()
                #
                # del (self.screen_name_list[i])
                # del (self.custom_tweet_list[i])
                #
                # print(f'index - {i} len - {len(self.screen_name_list)}')
                #
                # if i == gls.random_num or len(self.screen_name_list) < gls.random_num:
                #     break

        except tweepy.TweepError as e:
            logging.error('Error occurred ' + str(e))

        except Exception as e:
            logging.error('Error occurred ' + str(e))

        finally:
            pass

        print(
            "screen_name_follower() has terminated after 5 iterations and deletions "
        )
        return len(self.screen_name_list)
Beispiel #8
0
def image_tweeter(single_image, single_tweet, single_hashtag):
    print("starting image_tweeter()")

    gls.log_file_writer()

    try:
        api.update_with_media(single_image, f"{single_tweet} {single_hashtag}")

        gls.sleep_time()

    except tweepy.TweepError as eu:
        logging.error('Error occurred ' + str(eu))

    finally:
        pass

    print("image_tweeter() has terminated")
Beispiel #9
0
def tweet_sender(single_handle, single_tweet, single_hashtag):
    print("starting tweet_sender()")

    gls.log_file_writer()

    try:
        api.update_status(f'hey @{single_handle}, {single_tweet} {single_hashtag}')

        gls.sleep_time()

    except tweepy.TweepError as ed:
        logging.error('Error occurred ' + str(ed))
        print('Error occurred ' + str(ed))

    finally:
        pass

    print("tweet_sender() has terminated")
Beispiel #10
0
def single_tweet_replier(single_tweet_text, tweet_id):
    print("starting single_tweet_replier()")

    gls.log_file_writer()

    refreshed_tweet = f"{single_tweet_text} #LessonsNotLearned"

    try:
        api.update_status(status=refreshed_tweet, in_reply_to_status_id=tweet_id[:-1])
        gls.sleep_time()

    except tweepy.TweepError as re:
        logging.error('Error occurred ' + str(re))

    except Exception as et:
        logging.error('Error occurred ' + str(et))

    finally:
        pass

    print("single_tweet_replier() has terminated ")
Beispiel #11
0
def twitter_user_follower(single_handle):
    print("starting twitter_user_follower()")

    gls.log_file_writer()
    try:

        print(f"creating friendship with: {single_handle}")

        api.create_friendship(screen_name=single_handle)

        gls.sleep_time()

    except tweepy.TweepError as ef:
        logging.error('Error occurred ' + str(ef))
        print('Error occurred ' + str(ef))

    except Exception as eg:
        logging.error('Error occurred ' + str(eg))

    finally:
        pass

    print("twitter_user_follower() has terminated")
Beispiel #12
0
    def custom_replier(self):
        gls.log_file_writer()

        try:
            print("replying to custom mentions...")
            last_seen_id = get_last_seen_id(self.value_holder_file)

            mentions = gls.api.mentions_timeline(last_seen_id, tweet_mode='extended')
            # print(mentions[0].__dict__.keys())  # converts list into dict and extracts all the keys
            #
            # print(mentions[0].text)
            # 1163451084704079873 for testing

            i = 0
            for single_mention in reversed(mentions):
                print(f"mention id {single_mention.id} - mention full text {single_mention.full_text}")
                last_seen_id = single_mention.id
                save_last_seen_id(last_seen_id, self.value_holder_file)

                gls.api.update_status(
                    f'{gls.random_hashtag()} {self.custom_message_list[randint(0, len(self.custom_message_list) - 1)]}, @{single_mention.user.screen_name}',
                    single_mention.id)
                i += 1

                time_slept = gls.sleep_time()

                del (self.custom_message_list[i])

                print(f'index - {i} len - {len(self.custom_message_list)}')

                if i == gls.random_num or len(self.custom_message_list) < gls.random_num:
                    break

            print("end of reply cycle")

        except tweepy.TweepError as e:
            logging.error('Error occurred ' + str(e))

        except Exception as e:
            logging.error('Error occurred ' + str(e))

        finally:
            pass

        print("custom_replier() has terminated after 5 iterations and deletions ")
Beispiel #13
0
    def wp_post(self, title, post, site, kw_list):
        wp_post_url = f'{site}/wp-admin/post-new.php'
        wp_title_xpath = '//*[@id="post-title-1"]'
        wp_post_xpath = '//*[@id="post-content-0"]'
        wp_publish_1_xpath = '//button[text()="Publish"]'
        code_editor_xpath = "//button[contains(.,'Code editor')]"
        prepub_checkbox_xpath = '//*[@id="inspector-checkbox-control-2"]'
        close_panel_xpath = '//*[@aria-label="Close panel"]'
        block_editor_dialog_xpath = '//*[@aria-label="Close dialog"]'
        drop_down_xpath = '//*[@aria-label="More tools & options"]'
        tags_xpath = "//button[contains(.,'Tags')]"
        tags_input_xpath = '//*[@id="components-form-token-input-0"]'

        print(f'kw list {kw_list}')

        try:
            self.driver.get(wp_post_url)
            time.sleep(10)
            self.driver.find_element_by_xpath(
                block_editor_dialog_xpath).click()  # disable modal
            self.driver.find_element_by_xpath(drop_down_xpath).click()
            gls.sleep_time()
            self.driver.find_element_by_xpath(code_editor_xpath).click()
            gls.sleep_time()
            self.driver.find_element_by_xpath(drop_down_xpath).click()
            gls.sleep_time()
            self.driver.find_element_by_xpath(wp_title_xpath).click()
            gls.sleep_time()
            self.driver.find_element_by_xpath(wp_title_xpath).send_keys(title)
            gls.sleep_time()
            self.driver.find_element_by_xpath(wp_post_xpath).click()
            gls.sleep_time()
            self.driver.find_element_by_xpath(wp_post_xpath).send_keys(post)
            gls.sleep_time()
            self.driver.find_element_by_xpath(tags_xpath).click()
            gls.sleep_time()
            self.driver.find_element_by_xpath(tags_input_xpath).send_keys(
                kw_list)
            gls.sleep_time()
            pub1_btn = self.driver.find_element_by_xpath(wp_publish_1_xpath)
            gls.sleep_time()
            pub1_btn.click()
            gls.sleep_time()
            prepub_checkbox = self.driver.find_element_by_xpath(
                prepub_checkbox_xpath)
            if prepub_checkbox.is_selected():
                prepub_checkbox.click()
            gls.sleep_time()
            close_btn = self.driver.find_element_by_xpath(close_panel_xpath)
            gls.sleep_time()
            close_btn.click()
            gls.sleep_time()
            pub1_btn.click()
            time.sleep(15)

        except Exception as ex:
            print("wp post error at ", ex)
            print(traceback.format_exc())

        try:
            WebDriverWait(self.driver, 3).until(
                EC.alert_is_present(), 'Timed out waiting for PA creation ' +
                'confirmation popup to appear.')
            alert = self.driver.switch_to.alert()
            alert.accept()
            print("alert accepted")
        except TimeoutException:
            print("no alert")
Beispiel #14
0
    def comment(self, random_post_url, random_comment, random_author,
                random_email, random_website):
        comment_xpath = '//*[@id="comment"]'
        author_xpath = '//*[@id="author"]'
        email_xpath = '//*[@id="email"]'
        url_xpath = '//*[@id="url"]'
        submit_xpath = '//*[@id="comment-submit"]'
        comment_frame_xpath = '//*[@id="jetpack_remote_comment"]'
        try:

            self.driver.get(random_post_url)
            time.sleep(7)

            # Scroll down to bottom
            # self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

            # scroll to element
            self.driver.execute_script(
                "arguments[0].scrollIntoView();",
                self.driver.find_element_by_xpath(comment_frame_xpath))
            gls.sleep_time()
            comm_frame = self.driver.switch_to.frame('jetpack_remote_comment')
            gls.sleep_time()
            self.driver.find_element_by_xpath(comment_xpath).send_keys(
                random_comment)
            gls.sleep_time()
            self.driver.find_element_by_xpath(author_xpath).send_keys(
                random_author)
            gls.sleep_time()
            self.driver.find_element_by_xpath(email_xpath).send_keys(
                random_email)
            gls.sleep_time()
            self.driver.find_element_by_xpath(url_xpath).send_keys(
                random_website)
            gls.sleep_time()
            self.driver.execute_script("window.scrollBy(0,100)", "")
            gls.sleep_time()
            submit_element = self.driver.find_element_by_xpath(submit_xpath)
            gls.sleep_time()
            submit_element.click()

        except Exception as em:
            print(f'comment Error occurred with url: {random_post_url}' +
                  str(em))
            print(traceback.format_exc())

        finally:
            print("comment() done")
Beispiel #15
0
            dld_twt_id_list = list(dld_tweet_dict.keys())
            dld_twt_id_len = len(dld_twt_id_list)
            single_twt_id = dld_twt_list[randint(0, dld_twt_id_len-1)]

            follower_list = list(follower_id_dict.values())
            follower_id_len = len(follower_list)
            single_follower = follower_list[randint(0, follower_id_len-1)]

            hashtag_list_len = len(hashtag_list)
            single_ht = hashtag_list[randint(0, hashtag_list_len-1)]

            s_image = image_list[randint(0, len(image_list)-1)]

            dm_sender(single_minion_id, f'{single_twt}   you might like this: " https://cool-giveaways.weebly.com/')

            gls.sleep_time()

            tweet_sender(single_handle=single_follower, single_tweet=single_twt, single_hashtag=single_ht)

            gls.sleep_time()

            twitter_user_follower(single_handle=single_follower)

            gls.sleep_time()

            custom_replier()

            gls.sleep_time()

            image_tweeter(single_image=s_image, single_tweet=gls.usa_giveaway, single_hashtag=single_ht)
Beispiel #16
0
    def comment(self, random_post_url, random_author, random_email,
                random_website):
        policy_xpath = '//*[@type="submit"]'
        comment_xpath = '//*[@id="comment"]'
        author_xpath = '//*[@id="author"]'
        email_xpath = '//*[@id="email"]'
        url_xpath = '//*[@id="url"]'
        print(f'POST BEING WORKED ON: {random_post_url}')

        random_num = randint(1, 100)

        if random_num % 2 == 0:
            author_name = random_author.capitalize()

        elif random_num % 3 == 0:
            author_name = random_author.upper()
        else:
            author_name = random_author

        try:

            self.driver.get(random_post_url)
            time.sleep(5)

            global extracted_post
            # extracted_post = self.wp_post_getter()
            random_comment = self.response_generator()
            time.sleep(10)

            try:
                gls.sleep_time()
                policy_element = self.driver.find_element_by_class_name(
                    'accept')
                gls.sleep_time()
                policy_element.click()
            except Exception as e:
                print("policy click error ", str(e))

            try:
                gls.sleep_time()
                policy_element = self.driver.find_element_by_xpath(
                    policy_xpath)
                gls.sleep_time()
                policy_element.click()
            except Exception as e:
                print("policy click error ", str(e))

            if self.jetpack_frame_finder() is not None:
                gls.sleep_time()
                self.driver.switch_to.frame('jetpack_remote_comment')
                gls.sleep_time()

            else:
                # scroll to element
                gls.sleep_time()
                try:
                    self.driver.execute_script(
                        "arguments[0].scrollIntoView();",
                        self.driver.find_element_by_xpath(url_xpath))
                    gls.sleep_time()
                except Exception as x:
                    print(x)

            self.driver.find_element_by_xpath(comment_xpath).send_keys(
                random_comment)
            gls.sleep_time()
            self.driver.find_element_by_xpath(author_xpath).send_keys(
                f'{author_name}')
            gls.sleep_time()
            self.driver.find_element_by_xpath(email_xpath).send_keys(
                random_email)

            # try:
            #     gls.sleep_time()
            #     self.driver.find_element_by_xpath(url_xpath).send_keys(random_website)
            #     gls.sleep_time()
            # except Exception as ex:
            #     print("url loader error: ", str(ex))

            self.driver.execute_script("window.scrollBy(0,150)", "")
            gls.sleep_time()

            submit_element_1 = self.comment_submit_finder(
            )  # '//*[@id="comment-submit"]'
            submit_element_2 = self.submit_finder()  # '//*[@id="submit"]'
            submit_element_3 = self.fl_comment_finder(
            )  # '//*[@id="fl-comment-form-submit"]'

            if submit_element_1 is not None:
                gls.sleep_time()
                submit_element_1.click()
                gls.sleep_time()
            elif submit_element_2 is not None:
                gls.sleep_time()
                submit_element_2.click()
                gls.sleep_time()
            elif submit_element_3 is not None:
                gls.sleep_time()
                submit_element_3.click()
                gls.sleep_time()

        except Exception as em:
            print(f'comment Error occurred with url: {random_post_url} ' +
                  str(em))
            print(traceback.format_exc())

            if 'invalid session id' in str(em):
                self.clean_up()

        finally:
            print("comment() done")
Beispiel #17
0
    def wp_post(self, title, post):
        wp_post_url = 'https://hobbie370330789.wordpress.com/wp-admin/post-new.php'
        wp_title_xpath = '//*[@id="post-title-0"]'
        wp_post_xpath = '//*[@aria-label="Empty block; start writing or type forward slash to choose a block"]'
        wp_publish_1_xpath = '//button[text()="Publish"]'
        prepub_checkbox_xpath = '//*[@id="inspector-checkbox-control-2"]'
        close_panel_xpath = '//*[@aria-label="Close panel"]'

        self.driver.get(wp_post_url)

        try:
            gls.sleep_time()
            time.sleep(20)
            self.driver.find_element_by_xpath(wp_title_xpath).send_keys(title)
            gls.sleep_time()
            self.driver.find_element_by_class_name(
                'block-editor-writing-flow__click-redirect').click()
            gls.sleep_time()
            self.driver.find_element_by_xpath(wp_post_xpath).send_keys(post)
            gls.sleep_time()
            pub1_btn = self.driver.find_element_by_xpath(wp_publish_1_xpath)
            gls.sleep_time()
            pub1_btn.click()
            gls.sleep_time()
            prepub_checkbox = self.driver.find_element_by_xpath(
                prepub_checkbox_xpath)
            if prepub_checkbox.is_selected():
                prepub_checkbox.click()
            gls.sleep_time()
            close_btn = self.driver.find_element_by_xpath(close_panel_xpath)
            gls.sleep_time()
            close_btn.click()
            gls.sleep_time()
            pub1_btn.click()
            time.sleep(15)

        except Exception as ex:
            print("wp post error at ", ex)
            print(traceback.format_exc())

        try:
            WebDriverWait(self.driver, 3).until(
                EC.alert_is_present(), 'Timed out waiting for PA creation ' +
                'confirmation popup to appear.')
            alert = self.driver.switch_to.alert()
            alert.accept()
            print("alert accepted")
        except TimeoutException:
            print("no alert")
Beispiel #18
0
def wp_post(title, post):
    wp_post_url = 'https://hobbie370330789.wordpress.com/wp-admin/post-new.php'
    wp_title_xpath = '//*[@id="post-title-0"]'
    wp_post_xpath = '//*[@aria-label="Empty block; start writing or type forward slash to choose a block"]'
    wp_publish_1_xpath = '//button[text()="Publish"]'
    prepub_checkbox_xpath = '//*[@id="inspector-checkbox-control-2"]'
    close_panel_xpath = '//*[@aria-label="Close panel"]'
    try:
        driver.get(wp_post_url)
        gls.sleep_time()
        time.sleep(20)

        driver.find_element_by_xpath(wp_title_xpath).send_keys(title)
        gls.sleep_time()
        driver.find_element_by_class_name('block-editor-writing-flow__click-redirect').click()
        gls.sleep_time()
        driver.find_element_by_xpath(wp_post_xpath).send_keys(post)
        gls.sleep_time()
        pub1_btn = driver.find_element_by_xpath(wp_publish_1_xpath)
        gls.sleep_time()
        pub1_btn.click()
        gls.sleep_time()
        prepub_checkbox = driver.find_element_by_xpath(prepub_checkbox_xpath)
        if prepub_checkbox.is_selected():
            prepub_checkbox.click()
        gls.sleep_time()
        close_btn = driver.find_element_by_xpath(close_panel_xpath)
        gls.sleep_time()
        close_btn.click()
        gls.sleep_time()
        pub1_btn.click()

    except Exception as ex:
        print("wp post error at ", ex)
        print(traceback.format_exc())