diff --git a/download_board_images.py b/download_board_images.py index 4e9f248..dfa8491 100644 --- a/download_board_images.py +++ b/download_board_images.py @@ -1,7 +1,10 @@ from py3pin.Pinterest import Pinterest import requests +import os -download_dir = '.' +download_dir = './pinterest_images/' +if not os.path.exists(download_dir): + os.makedirs(download_dir) pinterest = Pinterest(email='email', password='password', @@ -18,7 +21,6 @@ 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']) @@ -26,6 +28,7 @@ # this can download images by url def download_image(url, path): + print("Downloading " + url) r = requests.get(url=url, stream=True) if r.status_code == 200: with open(path, 'wb') as f: diff --git a/py3pin/Pinterest.py b/py3pin/Pinterest.py index e45d304..32f274d 100644 --- a/py3pin/Pinterest.py +++ b/py3pin/Pinterest.py @@ -626,6 +626,7 @@ def search(self, scope, query, page_size=250): """ Gives access to pinterest search api This method is batched, meaning is needs to be called until empty list is returned. + NOTE: there is a max number of results set by Pinterest -> 1000 :param scope: can be pins, buyable_pins, my_pins, videos, boards :param query: search phrase :param page_size: batch size diff --git a/py3pin/RequestBuilder.py b/py3pin/RequestBuilder.py index 0a72f4b..2bb34aa 100644 --- a/py3pin/RequestBuilder.py +++ b/py3pin/RequestBuilder.py @@ -27,7 +27,9 @@ def buildGet(self, url, options, source_url='/', context=None): '_': '%s' % int(time.time() * 1000) }) - return '{}/?{}'.format(url, data) + url = '{}/?{}'.format(url, data) + url = url.replace('/get//?', '/get/?') + return url def url_encode(self, query): if isinstance(query, str): diff --git a/py3pin/__version__.py b/py3pin/__version__.py index 1a72d32..7b344ec 100644 --- a/py3pin/__version__.py +++ b/py3pin/__version__.py @@ -1 +1 @@ -__version__ = '1.1.0' +__version__ = '1.1.2'