Пример #1
0
 def __create_obj(self):
     self.__pinterest = Pinterest(email=self.__cfg['email'],
                                  password=self.__cfg['password'],
                                  username=self.__cfg['username'],
                                  cred_root=self.__cfg['cred_root'],
                                  user_agent=self.__cfg['user_agent'])
     self.__pinterest.login()
     self.__logger.info(f"{self.__cfg['username']} login")
     self.__boards = self.__pinterest.boards()
Пример #2
0
def lox():
    pinterest = Pinterest(email='*****@*****.**',
                          password='******',
                          username='******',
                          cred_root='logs/')

    search_batch = pinterest.search(query='neko chan', scope='pins')
    print(search_batch)

    neko = nekos.img(target='neko')
    print(neko)
Пример #3
0
class PinUploader:
    def __init__(self, cfg, logger):
        self.__cfg = cfg
        self.__pinterest = None
        self.__logger = logger
        self.__boards = None
        self.__create_obj()

    def __create_obj(self):
        self.__pinterest = Pinterest(email=self.__cfg['email'],
                                     password=self.__cfg['password'],
                                     username=self.__cfg['username'],
                                     cred_root=self.__cfg['cred_root'],
                                     user_agent=self.__cfg['user_agent'])
        self.__pinterest.login()
        self.__logger.info(f"{self.__cfg['username']} login")
        self.__boards = self.__pinterest.boards()

    def logout(self):
        self.__pinterest.logout()
        self.__logger.info(f"{self.__cfg['username']} logout")

    def __find_board_id(self, boardname):
        for board in self.__boards:
            if boardname == board['name']:
                return board['id']

    def get_board_id(self, boardname):
        response = None
        board_id = self.__find_board_id(boardname)
        if board_id:
            return board_id
        response = self.__pinterest.create_board(name=boardname)
        if response is not None:
            board_id = response.json()['resource_response']['data']['id']
            self.__logger.info("board {boardname} created")
            self.__boards.append({'name': boardname, 'id': board_id})
            return board_id
        else:
            self.__logger.error("can't create board '{boardname}'")
            return None

    def create_pin(self, board_id, title, price, image_path, printbar_url):
        description = '''Принт выдерживает неограниченное количество стирок.
                         Выберите тип ткани и вид печати.
                         Продукция будет готова через 48 часов.'''
        hashtag = title.replace(' ', ' #')
        try:
            self.__pinterest.upload_pin(
                board_id=board_id,
                image_file=image_path,
                description=f"Цена: {price}. {description} {hashtag}",
                link=printbar_url,
                title=title)
        except requests.exceptions.HTTPError:
            self.__logger.error("can't create '{title}' pin")
            raise
        else:
            self.__logger.info("'{title}' pin created ")
Пример #4
0
    '2020-04-07', '2020-04-08', '2020-04-09', '2020-04-10', '2020-04-11',
    '2020-04-12', '2020-04-13', '2020-04-14', '2020-04-15', '2020-04-16',
    '2020-04-17', '2020-04-18', '2020-04-19', '2020-04-20', '2020-04-21',
    '2020-04-22', '2020-04-23', '2020-04-24', '2020-04-27', '2020-04-28',
    '2020-04-29', '2020-04-30', '2020-05-01', '2020-05-02', ''
]

import requests
import datetime
import sys
from time import sleep
from py3pin.Pinterest import Pinterest
from PIL import Image, ImageDraw, ImageFont

pinterest = Pinterest(email='*****@*****.**',
                      password='******',
                      username='******')
try:
    pinterest.login()
except:
    print("Pas besoin de connection.")

journaldespace_url = 'https://imobinfo.com/Actualites.html'

nasa = 'https://api.nasa.gov/planetary/apod'
nasa_params = {
    'api_key': 'IqWPpNh7NbhokTuyrrkaJqjXXXHkShByHQ5uta7h',
}
yandex = 'https://translate.yandex.net/api/v1.5/tr.json/translate'
yandex_params = {
    'key':
Пример #5
0
def getPinterestUserPinnedSubmissions(email, username, password,
                                      cacheFileName):

    submissions = []

    lastIds = {} if not cacheFileName else loadPinterestCache(cacheFileName)
    updatedLastIds = lastIds

    pinterest = Pinterest(email=email,
                          password=password,
                          username=username,
                          cred_root='pinterest_creds')

    logger.log("Logging in to Pinterest...")
    pinterest.login()

    boards = pinterest.boards(username=username)

    for board in boards:
        # Get all pins for the board
        board_pins = []
        pin_batch = pinterest.board_feed(board_id=board['id'])

        while len(pin_batch) > 0:
            for pin in pin_batch:
                if pin['id'] not in lastIds:
                    # Only using the dict for its key lookup
                    updatedLastIds[pin['id']] = 1
                    board_pins.append(pin)

            pin_batch = pinterest.board_feed(board_id=board['id'])

        for pin in board_pins:

            # I'm not sure how important it is to support these
            if pin['type'] == 'story':
                continue

            newSubmission = Submission()
            newSubmission.source = u'Pinterest'
            # While pins do have titles, 90% of the time they seem useless
            newSubmission.title = pin['id']
            # There is probably a way to figure out who the original pinner is, but oh well
            newSubmission.author = 'N/A'
            newSubmission.subreddit = board['url']
            newSubmission.subredditTitle = board['name'] + '_Pinterest'
            if 'rich_summary' in pin and pin['rich_summary']:
                if 'display_description' in pin['rich_summary']:
                    newSubmission.body = pin['rich_summary'][
                        'display_description']
                else:
                    newSubmission.body = 'N/A'
                newSubmission.postUrl = pin['rich_summary']['url']

            # What is actually downloaded
            newSubmission.bodyUrl = pin['images']['orig']['url']
            submissions.append(newSubmission)

    if cacheFileName:
        savePinterestCache(cacheFileName, updatedLastIds)

    logger.log("Found {} new Pinterest submissions".format(len(submissions)))
    return submissions
from py3pin.Pinterest import Pinterest
import requests

username = '******'
password = '******'
email = 'login email'
cred_root = 'some dir'
download_dir = 'dir where images will be downloaded'

pinterest = Pinterest(email=email,
                      password=password,
                      username=username,
                      cred_root=cred_root)

# login if needed
# pinterest.login()

# your boards, pick one
boards = pinterest.boards()

# for example the first one
target_board = boards[0]

# get all pins for the board
board_pins = []
pin_batch = pinterest.board_feed(board_id=target_board['id'],
                                 board_url=target_board['url'])

while len(pin_batch) > 0:
    board_pins += pin_batch
    pin_batch = pinterest.board_feed(board_id=target_board['id'],
Пример #7
0
from py3pin.Pinterest import Pinterest

pinterest = Pinterest(email='email',
                      password='******',
                      username='******',
                      cred_root='cred_root')

# proxies example:
# proxies = {"http":"http://*****:*****@proxy_ip:proxy_port"}
# Pinterest(email='emai', password='******', username='******', cred_root='cred_root', proxies=proxies)

# login will obtain and store cookies for further use, they last around 15 days.
# NOTE: Since login will store the cookies in local file you don't need to call it more then 3-4 times a month.
# pinterest.login()


def get_user_profile():
    return pinterest.get_user_overview(username='******')


def get_user_boards_batched(username=None):
    boards = []
    board_batch = pinterest.boards(username=username)
    while len(board_batch) > 0:
        boards += board_batch
        board_batch = pinterest.boards(username=username)

    return boards


def get_boards(username=None):
from py3pin.Pinterest import Pinterest
import requests

download_dir = 'dir where images will be downloaded'

pinterest = Pinterest(email='email',
                      password='******',
                      username='******',
                      cred_root='cred_root')

# your boards, pick one
boards = pinterest.boards()

# for example the first one
target_board = boards[0]

# get all pins for the board
board_pins = []
pin_batch = pinterest.board_feed(board_id=target_board['id'])

while len(pin_batch) > 0:
    board_pins += pin_batch
    pin_batch = pinterest.board_feed(board_id=target_board['id'])


# this can download images by url
def download_image(url, path):
    r = requests.get(url=url, stream=True)
    if r.status_code == 200:
        with open(path, 'wb') as f:
            for chunk in r.iter_content(1024):
Пример #9
0
from py3pin.Pinterest import Pinterest
from PIL import Image
import requests
from io import BytesIO


def download_image(url, path):
    r = requests.get(url=url, stream=True)
    if r.status_code == 200:
        with open(path, 'wb') as f:
            for chunk in r.iter_content(1024):
                f.write(chunk)


pinterest = Pinterest(email='*****@*****.**',
                      password='******',
                      username='******',
                      cred_root='cred_root')

allpins = pinterest.search(scope='pins', query='something')
images = []
for pin in allpins:
    origUrl = pin['images']['orig']['url']
    images.append(origUrl)

i = 0
for url in images:
    #indx = str(url).rfind('.')
    #extension = str(url)[indx:]
    #download_image(url,  "img/" + str(i) + extension)
    response = requests.get(url)
    img = Image.open(BytesIO(response.content))
Пример #10
0
api.update_with_media(temp, status=msg)
os.remove(temp)

# # Instagram

bot = instabot.Bot()
bot.login(username="******", password="******")
temp = 'temp.jpg'
request = requests.get(thumb, stream=True)

with open(temp, 'wb') as image:
    for chunk in request:
        image.write(chunk)
bot.upload_photo(temp, caption=msg)
os.remove(temp + ".REMOVE_ME")

# # Pinterest

pinterest = Pinterest(email='*****@*****.**',
                      password='******',
                      username='******',
                      cred_root='cred_dir')

pinterest.login()
pinterest.pin(board_id="802203821065010593",
              image_url=thumb,
              description=msg,
              title=title,
              link=current_post_url)
Пример #11
0
from py3pin.Pinterest import Pinterest

username = '******'
password = '******'
email = 'email'
# cred_root is the place the user sessions and cookies will be stored you should specify this to avoid permission issues
cred_root = 'cred_root'

pinterest = Pinterest(email=email,
                      password=password,
                      username=username,
                      cred_root=cred_root)

results = []
max_results = 100
batch_size = 50
query = 'food'

# Due to recent changes in pinterest api we can't directly search for users.
# instead we search for something else and extract pinners, owners and the relevant data
search_batch = pinterest.search(scope='pins',
                                query=query,
                                page_size=batch_size)
while len(search_batch) > 0 and len(results) < max_results:
    results += search_batch
    pinterest.search(scope='pins', query=query, page_size=batch_size)

target_users = []
for s in results:
    target_users.append(s['owner'])
Пример #12
0
from py3pin.Pinterest import Pinterest
import requests

download_dir = './img/'

img_id = 1

pinterest = Pinterest(email='@gmail.com',
                      password='',
                      username='',
                      cred_root='./img')

# your boards, pick one
boards = pinterest.boards()

# for example the first one
target_board = boards[0]

# get all pins for the board
board_pins = []
pin_batch = pinterest.board_feed(board_id=target_board['id'])


while len(pin_batch) > 0:
    board_pins += pin_batch
    pin_batch = pinterest.board_feed(board_id=target_board['id'])


# this can download images by url
def download_image(url, path):
    r = requests.get(url=url, stream=True)
Пример #13
0
from py3pin.Pinterest import Pinterest

pinterest = Pinterest(email='email',
                      password='******',
                      username='******',
                      cred_root='cred_root')

# to release
# python3 setup.py sdist & twine upload --skip-existing dist/*
# proxies example:
# proxies = {"http":"http://*****:*****@proxy_ip:proxy_port"}
# Pinterest(email='emai', password='******', username='******', cred_root='cred_root', proxies=proxies)


# login will obtain and store cookies for further use, they last around 15 days.
# NOTE: Since login will store the cookies in local file you don't need to call it more then 3-4 times a month.
# pinterest.login()

def get_user_profile():
    return pinterest.get_user_overview(username='******')


def get_user_boards_batched(username=None):
    boards = []
    board_batch = pinterest.boards(username=username)
    while len(board_batch) > 0:
        boards += board_batch
        board_batch = pinterest.boards(username=username)

    return boards
Пример #14
0
from py3pin.Pinterest import Pinterest

username = "******"
password = "******"
email = "email"
# cred_root is the place the user sessions and cookies will be stored you should specify this to avoid permission issues
cred_root = "cred_root"

pinterest = Pinterest(email=email,
                      password=password,
                      username=username,
                      cred_root=cred_root)
pinterest.login()
followers = pinterest.get_board_followers(213428538529906246)

print(followers[:10])
Пример #15
0
from py3pin.Pinterest import Pinterest

pinterest = Pinterest(email='*****@*****.**',
                      password='******',
                      username='******')

pinterest = Pinterest(email='*****@*****.**',
                      password='******',
                      username='******')

print(pinterest.login())


def get_user_profile():
    return pinterest.get_user_overview(username='******')


def get_user_boards(username=None):
    boards = []
    board_batch = pinterest.boards(username=username)
    while len(board_batch) > 0:
        boards += board_batch
        board_batch = pinterest.boards(username=username)

    return boards


def get_board_pins(board_id=''):
    board_feed = []
    feed_batch = pinterest.board_feed(board_id=board_id)
    while len(feed_batch) > 0:
Пример #16
0
from py3pin.Pinterest import Pinterest

username = '******'
password = '******'
email = 'email'
# cred_root is the place the user sessions and cookies will be stored you should specify this to avoid permission issues
cred_root = 'cred_root'

pinterest = Pinterest(email=email,
                      password=password,
                      username=username,
                      cred_root=cred_root)


# get the user id by username
def get_user_id(username):
    return pinterest.get_user_overview(username=username)['id']


# Pinterest conversations are stored in a list of conversation object on their side.
# Each converastion has id and last message they use to display on the initial drop down once you click the message button
def get_all_conversations():
    return pinterest.get_conversations()


# Once you obtain a conversation id, only then you can see all the messages and participants in it.
def load_conversation(conversation_id):
    return pinterest.load_conversation(conversation_id=conversation_id)


# in order to have conversation with some one, it needs to be initialized once with some initial message
Пример #17
0
from py3pin.Pinterest import Pinterest

username = '******'
password = '******'
email = 'email'
cred_root = 'some directory'
# cred_root is the place the user sessions and cookies will be stored, you should specify this to avoid permission issues
pinterest = Pinterest(email=email,
                      password=password,
                      username=username,
                      cred_root='/home/kashon/py3pin')


def login():
    # don't spam this, or they will lock the account
    return pinterest.login()


def get_user_profile():
    return pinterest.get_user_overview()


def get_user_boards():
    # load specific user boards
    # board_batch = pinterest.boards(username='******')

    # load current user boards
    boards = []
    board_batch = pinterest.boards()
    while len(board_batch) > 0:
        boards += board_batch
Пример #18
0
from py3pin.Pinterest import Pinterest

username = '******'
password = '******'
email = 'email'
# cred_root is the place the user sessions and cookies will be stored you should specify this to avoid permission issues
cred_root = 'cred_root'

pinterest = Pinterest(email=email,
                      password=password,
                      username=username,
                      cred_root=cred_root)


def search_boards():
    results = []
    max_results = 100
    batch_size = 50
    query = 'food'
    scope = 'boards'

    # Obtain a list of boards we want to follow
    search_batch = pinterest.search(scope=scope, query=query, page_size=batch_size)
    while len(search_batch) > 0 and len(results) < max_results:
        results += search_batch
        pinterest.search(scope=scope, query=query, page_size=batch_size)

    return results

def search_users():
    # pinterest no longer allows to search for users, we will search for pins and extract the pinners
Пример #19
0
def autoload(ch):
    global config
    global pinterest
    ch.add_command({
        "trigger": ["!debug_prt"],
        "function":
        lambda message, client, args: get_boards(args[0]),
        "async":
        False,
        "admin":
        False,
        "hidden":
        True,
        "args_num":
        1,
        "args_name": ["username"],
        "description":
        "Return a random image from the board specified",
    })
    ch.add_command({
        "trigger": ["!prt"],
        "function":
        pinterest_randomize_function,
        "async":
        True,
        "admin":
        False,
        "hidden":
        True,
        "args_num":
        2,
        "args_name": ["username", "board"],
        "description":
        "Return a random image from the board specified",
    })
    ch.add_command({
        "trigger": ["!possum"],
        "function":
        lambda message, client, args: pinterest_randomize_function(
            message, client, ["jerryob1", "Opossums"]),
        "async":
        True,
        "admin":
        False,
        "hidden":
        False,
        "args_num":
        0,
        "args_name": ["username", "board"],
        "description":
        "Return a random image from the board specified",
    })
    # for guild in ch.guilds:
    #     for ch.config.get(guild=guild, section="pinterest"):
    pinterest = Pinterest(
        email=ch.config.get(section="pinterest", key="email"),
        password=ch.config.get(section="pinterest", key="password"),
        username=ch.config.get(section="pinterest", key="username"),
        cred_root=ch.config.get(section="pinterest", key="tmpdir"),
    )
    if datetime.datetime.now() == 8:
        pinterest.login()
    print('Section count: ' + str(board['section_count']) + ' ')


def dump_board(file, board):
    if board['owner']['username'] == sai.USER:
        print_board(board)
        title = '<h1>' + str(board['name']) + '</h1>'
        data = '<div>' + str(board['pin_count']) + ' pins</div>'
        data += '<div>' + str(board['section_count']) + ' sections</div>'
        board_data = title + data + '\r\n'
        file.write(board_data)
        fetch_pins(file, board)


pinterest = Pinterest(email=sai.EMAIL,
                      password=sai.PWD,
                      username=sai.USER,
                      cred_root='cred_root')

# your boards
boards = pinterest.boards()

file = open('./index.html', "w+", encoding="utf-8")
file.write(
    '<html lang="en"><head><meta charset="UTF-8"><title>Pinterest Archive</title></head><body>\r\n'
)
for board in boards:
    dump_board(file, board)
    file.flush()

file.write('</body>')
file.close()