Skip to content

Commit

Permalink
Release 1.1.0 (#63)
Browse files Browse the repository at this point in the history
* update download images example

* minor

* Improved docs, added logout and some utility methods
  • Loading branch information
bstoilov committed Jun 20, 2020
1 parent d13cf5f commit a38b48c
Show file tree
Hide file tree
Showing 3 changed files with 336 additions and 17 deletions.
27 changes: 22 additions & 5 deletions README.md
@@ -1,7 +1,8 @@
# py3-pinterest
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Unofficial Pinterest API implemented in python 3 that can do almost all pinterest tasks like comment, pin, repin, follow, unfollow and more.
Unofficial Pinterest API implemented in python 3 that can do all Pinterest tasks like comment, pin, repin, follow, unfollow and more.

It is implemented by directly calling the pinterest servers, mimicking an actual browser, so you don't need pinterest API key.

If you see any issues, or find bugs feel free to report them here on the github repo.
Expand All @@ -18,16 +19,26 @@ If you see any issues, or find bugs feel free to report them here on the github
```pinterest = Pinterest(email='your email goes here', password='password goes here', username='look in pinterest url', cred_root='cred root dir')```

cred_root is the dir (automatically created if missing) that will store some cookies nad sessions, so you don't need to login before each request.
Make sure you specify a path with read/write persmissions.
Make sure you specify a path with read/write permissions.

Proxies example:

```
proxies = {"http":"http://username:password@proxy_ip:proxy_port"}
Pinterest(email='emai', password='pass', username='name', cred_root='cred_root', proxies=proxies)
```

# The following features are currently supported

## Login/Logout
Login will store auth cookies for later use. These cookies are usually valid for ~15 days, then you will start getting 403 and 401 errors, which means you need to call login again.
## Login
Login is required to permit actions to the Pinterest servers. Login will store auth cookies for later use. These cookies are usually valid for ~15 days, then you will start getting 403 and 401 errors, which means you need to call login again.

```pinterest.login()```

```pinterest.logout()```



## Load profile
Expand Down Expand Up @@ -100,8 +111,14 @@ A pinterest feature they use to pin from websites

### Pin

Pin image by web url:

```pinterest.pin(board_id=board_id, image_url=image_url, description=description, title=title)```

Pin image from local file:

```pinterest.upload_pin(board_id=board_id, section_id=section_id, image_file=image_path, description=description, title=title, link=link)```

### Get home feed pins

``` home_feed_batch = pinterest.home_feed()```
Expand All @@ -110,11 +127,11 @@ A pinterest feature they use to pin from websites

```rec_batch = pinterest.board_recommendations(board_id=board_id)```

### Get pin by id
### Get pin information by id

```pinterest.load_pin(pin_id='pin_id')```

### Section support
### Board Section support
```pinterest.create_board_section(board_id=board_id, section_name=section_name)```
```pinterest.delete_board_section(section_id=section_id)```
```pinterest.get_board_sections(board_id=board_id)```
Expand Down Expand Up @@ -161,7 +178,7 @@ If username is not provided current user will be used

```search_batch = pinterest.search(scope='boards', query='food')```

Current pinterest scopes are: pins, buyable_pins, my_pins, videos, users, boards
Current pinterest scopes are: pins, buyable_pins, my_pins, videos, boards


## User interactions
Expand Down
31 changes: 24 additions & 7 deletions examples.py
Expand Up @@ -5,16 +5,20 @@
username='username',
cred_root='cred_root')

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

# login is required to perform further actions. Login will obtain and store cookies for further use, they last around 15 days.
pinterest.login()

# 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='username')


def get_user_boards(username=None):
def get_user_boards_batched(username=None):
boards = []
board_batch = pinterest.boards(username=username)
while len(board_batch) > 0:
Expand All @@ -24,7 +28,11 @@ def get_user_boards(username=None):
return boards


def get_board_pins(board_id=''):
def get_boards(username=None):
return pinterest.boards_all(username=username)


def get_board_pins_batched(board_id=''):
board_feed = []
feed_batch = pinterest.board_feed(board_id=board_id)
while len(feed_batch) > 0:
Expand All @@ -49,7 +57,7 @@ def unfollow(user_id=''):
return pinterest.unfollow_user(user_id=user_id)


def get_following(username=None, max_items=500):
def get_following_batched(username=None, max_items=500):
# you can get following on any user, default is current user
# pinterest.get_following(username='some_user')

Expand All @@ -62,7 +70,12 @@ def get_following(username=None, max_items=500):
return following


def get_followers(username=None, max_items=500):
def get_following(username=None):
# Gets full following list of a user
return pinterest.get_following_all(username=username)


def get_followers_batched(username=None, max_items=500):
followers = []
followers_batch = pinterest.get_user_followers(username=username)
while len(followers_batch) > 0 and len(followers) < max_items:
Expand All @@ -72,6 +85,11 @@ def get_followers(username=None, max_items=500):
return followers


def get_followers(username=None):
# Gets a full list of user followers
return pinterest.get_user_followers_all(username=username)


def get_home_feed(max_items=100):
# This is what pinterest displays on your home page
# useful for auto repins
Expand Down Expand Up @@ -204,4 +222,3 @@ def get_board_sections(board_id=''):

def get_board_section_feed(section_id=''):
return pinterest.get_section_pins(section_id=section_id)

0 comments on commit a38b48c

Please sign in to comment.