Don't Scroll Past - Tumblr Posts

8 months ago

import requests

from requests_oauthlib import OAuth1

import json

import time

from selenium import webdriver

from selenium.webdriver.chrome.service import Service

from selenium.webdriver.common.by import By

from selenium.webdriver.chrome.options import Options

from selenium.common.exceptions import NoSuchElementException

import pickle

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.support.ui import WebDriverWait

from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.common.action_chains import ActionChains

import pyperclip

# Replace these values with your Tumblr API credentials

CONSUMER_KEY = 'IPTeKkiLSZ2wQ1io5vo5G37AN2thcbSwXOJgqL4SjHV2wLoNce'

CONSUMER_SECRET = 'lE97QdUIAj7svMGDznbcxmsFubj1iIr06hHJ4cLGCaM2wedIio'

TOKEN = 'wovWkA5KSv6XAbMvf5gkAr2V0hGyoRpxbdgM0uoN6qsSzg5OsI'

TOKEN_SECRET = 'gkDd6pBbvsPbUp0Eh95AQQp2CQi5qFzKNtvJ0qPo0far60BqxD'

# CONSUMER_KEY = 'wye8qq5zYT875se51OwUNwPaUvFjvE5ONkzYZ2nsgkoEXnUQfv'

# CONSUMER_SECRET = 'QxLe87coDa0NFzCZRS4KR6gOCxRIEzMqLzOVrH0hc1CVsUjJ35'

# TOKEN = 'fweQkfHHtNWgWiS8KOOFA6bzljfA47cldg44FkljdUbtaV51Uz'

# TOKEN_SECRET = 'l9uS5eLJ2XkRb8D93avCUTeLdxp6m8zDwUTTClgpNZjDGHYMFc'

# CONSUMER_KEY = 'ncRYD9hDIu0uV1tFk2bTxm2F3UDuZ1kM6gsTKO7TAIv9ZQ3rcW'

# CONSUMER_SECRET = '94lTdrh6izgyqP79aSI0HpBSvLAg4PiNRzYEHZTxGWrhWsr4MJ'

# TOKEN = 'vdPho0RVxZANZKVV02HzKKGDVbwMbMNdDckj1dy6GEqIXPvsX3'

# TOKEN_SECRET = '4f7Wfm8oc4mZ94BEH2z9P7fcOHt1tm8AoI3LoAThfKsZ1gWFSz'

# Tumblr API endpoints

BASE_URL = "https://api.tumblr.com/v2"

SENT_ASKS_FILE = "sent_asks.json"

BLOG_NAME = "abedalazeiz"

POST_ID = "756236689516691456"

ASK_MESSAGE = ("I know for sure that you can't help all families from Gaza that want to be evacuated from here but at least you can help those who come across your life. You have no idea how mentally and emotionally tiring this is. Asking for help is not easy. But when thinking that the price is my family's life and getting out of here safely, it just pushes me more and more to do this until i reach my goal, be able to attend my university abroad and achieve my doctoral degree dream after awarding prestigious PhD fellowship. Please donate and share to support us standing at this hard time.\n https://gofund.me/d597b8e2")

# OAuth 1.0a authentication

auth = OAuth1(CONSUMER_KEY, CONSUMER_SECRET, TOKEN, TOKEN_SECRET)

# = ""

options = webdriver.ChromeOptions()

options.add_argument("--disable-blink-features=AutomationControlled")

options.add_argument("--start-maximized")

options.add_experimental_option('excludeSwitches', ['enable-automation'])

options.add_experimental_option('useAutomationExtension', False)

options.page_load_strategy = 'none' #eager

driver = webdriver.Chrome(options=options)

driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {

    "source": """

        Object.defineProperty(navigator, 'webdriver', {

          get: () => undefined

        })

      """

})

def load_sent_asks():

    try:

        with open(SENT_ASKS_FILE, 'r') as file:

            sent_asks = json.load(file)

            print(f"Loaded sent asks: {sent_asks}")

            return sent_asks

    except FileNotFoundError:

        print("No sent asks file found, starting fresh.")

        return []

def save_sent_asks(sent_asks):

    with open(SENT_ASKS_FILE, 'w') as file:

        json.dump(sent_asks, file)

def get_reblogs(after=None):

    url = f"{BASE_URL}/blog/{BLOG_NAME}/notes?id={POST_ID}&mode=likes&limit=20" #reblogs

    if after:

        url += f"&after={after}"

    print(f"Fetching reblogs from URL: {url}")

    response = requests.get(url, auth=auth)

    response.raise_for_status()

    return response.json()

def send_ask(account_name):

    print(f"Sending ask to {account_name}")

    driver.get(f"https://www.tumblr.com/new/ask/{account_name}")

    driver.implicitly_wait(40)

    actions = ActionChains(driver)

    try:

        #loadingSelector = '#glass-container > div > div > div > div > div > div > div.Y21sU > div > div.oDBam > div > div'

        #WebDriverWait(driver, 30).until(EC.invisibility_of_element_located(driver.find_element(By.CSS_SELECTOR, loadingSelector)))

        #actions.key_down(Keys.ENTER).key_up(Keys.ENTER).perform()

        field = driver.find_element(By.CSS_SELECTOR, '#glass-container > div > div > div > div > div > div > div.Y21sU > div > div.oDBam > div:nth-child(2) > div > div:nth-child(4) > div.block-editor-writing-flow > div > div')

        field.send_keys("\n")

        actions.key_down(Keys.LEFT_CONTROL).send_keys('v').key_up(Keys.LEFT_CONTROL).perform()

        askselector = '#glass-container > div > div > div > div > div > div > div.Y21sU > div > div.Q1jRN > div > div > div > button > span'

        ask = driver.find_element(By.CSS_SELECTOR, askselector)

        ask.click()

        WebDriverWait(driver, 60).until(EC.invisibility_of_element_located(ask))

    except Exception as e:

        print("hmmm")

def main():

    print("Starting script...")

    sent_asks = load_sent_asks()

    previousSave = len(sent_asks)

    after = None

    pyperclip.copy(ASK_MESSAGE)

    try:

        with open('cookies.pkl', 'rb') as file:

            cookies = pickle.load(file)

        driver.get('https://www.tumblr.com')

        for cookie in cookies:

            driver.add_cookie(cookie)

        #driver.refresh()

    except FileNotFoundError:

        driver.get('https://www.tumblr.com/login')

        input("Log in to Tumblr and then press Enter to continue...")

        cookies = driver.get_cookies()

        with open('cookies.pkl', 'wb') as file:

            pickle.dump(cookies, file)

    while True:

        data = get_reblogs(after=after)

        reblogs = data.get('response', {}).get('notes', [])

        if not reblogs:

            break

        for reblog in reblogs:

            account_name = reblog['blog_name']

            if account_name in sent_asks:

                print(f"Already sent ask to {account_name}, skipping.")

                continue

            try:

                url = f"https://api.tumblr.com/v2/blog/{account_name}/info"

                response = requests.get(url, auth=auth)

                if response.status_code == 200:

                    blog_info = response.json().get('response', {}).get('blog', {}).get('ask', False)

                    if blog_info:

                        send_ask(account_name)

                        sent_asks.append(account_name)

                        save_sent_asks(sent_asks)

                    else:

                        print(f"{account_name} doesn't accept asks")

                else:

                    return print("request not available")

            except requests.exceptions.HTTPError as e:

                print(f"Failed to process {account_name}")

        after = data.get('response', {}).get('_links', {}).get('next', {}).get('href')

        if not after:

            break

    # url = f"https://api.tumblr.com/v2/blog/impossiblebool/info"

    # response = requests.get(url, auth=auth)

    # if response.status_code == 200:

    #     blog_info = response.json().get('response', {}).get('blog', {}).get('ask', False)

    #     send_ask("impossiblebool")

    # else:

    #     return print(f"impossiblebool doesn't accept asks>>>>")

    print(f"Script finished, new sent asks number: {len(sent_asks) - previousSave}")

if __name__ == "__main__":

    main()

Donate to Help my family survive famine and have secure life, organized by Mazin Fakak
gofundme.com
Dear friends, family, and compassionate supporters, My name is Eman Za… Mazin Fakak needs your support for Help my family survive famine an

This has been vetted. Please share, and donate if you can <3


Tags :
8 months ago

Hello my freind 👋

Please help my family and our children survive the genocide and find a new life away from death 🙏🥺

Please, donate, share, reblog to save our live 💔

https://www.gofundme.com/f/Stand-With-AlBalawi-Family

Donate to Help save my family to survive the genocide in Gaza, organized by Mahmoud AlBalawi
gofundme.com
Hi world , it’s Mahmoud Please read this as if you were in my… Mahmoud AlBalawi needs your support for Help save my family to survive th

This has been vetted. Please share and donate if you are able


Tags :
7 months ago

This is Eman a Biotechnologist from Gaza. Asking for help is not easy. It's not easy at all. You have no idea how mentally and emotionally tiring this is. But when thinking that the price is my family's life, getting out of here safely and achieve my doctoral degree dream, it just pushes me more and more to do this until we reach our goal. I'm here as I try to reach out to more people asking for their help to support our family's campaign so we can survive while all you have to do is literally donating even by just the price of your morning coffee or maybe a simple breakfast, So I think I'm not asking for so much. We're really tired of living under these catastrophic conditions for a whole 10 months. Your generosity will not only change our lives but also remind us that even in our darkest hour, we are not alone. https://gofund.me/d597b8e2

Donate to Help Reunite a Family Torn A part by the War, organized by Jumana Elmadhoun
gofundme.com
My name is Jumana Elmadhoun I am writing on behalf of… Jumana Elmadhoun needs your support for Help Reunite a Family Torn

This has been vetted. Please share and donate if you are able <3


Tags :
7 months ago

Hello, I hope you're doing well! My name is Mahmoud Abu Swierh, and I'm a 17-year-old from Gaza. The ongoing war has devastated my city, destroyed my school, and made daily life incredibly challenging. Despite these hardships, I'm determined to continue my education and build a better future. I've been given a chance to study abroad, but I need help to cover the costs of leaving Gaza, as well as living expenses and other essentials abroad once the crossing opens. If you can, please consider donating or sharing, your kindness can truly make a difference. Thank you. https://gofund.me/bd3ccf0b

Donate to Help Mahmoud from Gaza Pursue His Dreams, organized by Mazin Fakak
gofundme.com
Hello, my name is Mahmoud Abu Swierh, and I am a 17-year-old from Al-Nuseirat in … Mazin Fakak needs your support for Help Mahmoud from Gaza

This has been vetted. Please share and donate if you can <3


Tags :
7 months ago

m Abdel Muti , I am 27 years old. I live in Palestine, Gaza. I am married and my wife is 23 years old. I have a daughter, Juri,maroan who is 2 years old and salmaa 6manth. We are displaced in southern Gaza. Our situation is very, very difficult, and I am afraid of losing my daughter and my family. Please, my friends, help me with my campaign so that we can travel outside Gaza from Please don't break the children's hear,Please do something and Help my family get out of these bad conditions we are living in, to get the decent life we ​​deserve, to survive, to live, to feel a life 🙏😔https://gofund.me/a4da9cf7

Donate to Help us for the sake of God, organized by Abdelmutei Alhabil
gofundme.com
I am the citizen Abdel Muti Al-Habil, a resident of Gaza. I am 26 years old. My wife … Abdelmutei Alhabil needs your support for Help us f

This has been vetted. Please share and donate if you can <3


Tags :
7 months ago

Please, my friend, donate to me. I need your support. My tent burned down and my husband and children were injured. Please,🙏🙏💔💔

Donate to Assist in evacuating my family from the  war in Gaza., organized by Mohammed Alhabil
gofundme.com
My name is Muhammad Al-Habil, a 30-year-old father of three fro… Mohammed Alhabil needs your support for Assist in evacuating my family from

This has been vetted. Please share and donate if you can, they are around half way through! <3


Tags :