Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.7 kB
1
Indexable
Never
import os
import sys
import random
import datetime
import requests
from bs4 import BeautifulSoup
from time import sleep
from getpass import getpass
from PIL import Image
from io import BytesIO


def clear():
    os.system('cls' if os.name == 'nt' else 'clear')


def wait():
    sleep(1)


def scroll():
    print('\n' * 200)


def login():
    email = input("Enter your email: ")
    password = getpass("Enter your password: ")

    response = requests.post(
        "https://www.facebook.com/login.php?login_attempt=1",
        headers={
            "Content-Type": "application/x-www-form-urlencoded"
        },
        data={
            "email": email,
            "pass": password,
            "login": "Log In"
        },
        allow_redirects=False
    )

    if 'Location' in response.headers:
        location = response.headers['Location']
        if location.startswith("https://www.facebook.com/"):
            return True

    print("Error occurred during login.")
    return False


def post_photo():
    if not login():
        return

    with open("path_to_image.jpg", "rb") as f:
        file = {
            "photo": (os.path.basename("path_to_image.jpg"), f)
        }

        response = requests.post(
            "https://www.facebook.com/photo.php",
            headers={
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
            },
            files=file,
            allow_redirects=False
        )

        if 'Location' in response.headers:
            location = response.headers['Location']
            if location.startswith("