Skip to content

Commit

Permalink
changes on the login and updates on the examples (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
bstoilov committed Jan 16, 2021
1 parent a905755 commit ed8e6b3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
20 changes: 10 additions & 10 deletions download_board_images.py
Expand Up @@ -18,22 +18,22 @@
# your boards, pick one
boards = pinterest.boards()

#delme
# delme
for board in boards:
target_board = board
print(target_board['name'])
if not os.path.exists(download_dir + target_board['name']):
os.makedirs(download_dir + target_board['name'])


# get all pins for the board
# 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):
global countrSkip
Expand All @@ -52,19 +52,19 @@ def download_image(url, path):
if nb_tries == 0:
raise err
else:
time.sleep(1)
time.sleep(1)
if r.status_code == 200:
countrDnld += 1
print("Downloading " + url)
with open(path, 'wb') as f:
for chunk in r.iter_content(1024):
f.write(chunk)
# download each pin image in the specified directory


# download each pin image in the specified directory
for pin in board_pins:
if 'images' in pin:
url = pin['images']['orig']['url']
download_image(url, download_dir + target_board['name'] + '/' + url.rsplit('/', 1)[-1])
print ("Existing files:" + str(countrSkip))
print ("New files:" + str(countrDnld))
print("Existing files:" + str(countrSkip))
print("New files:" + str(countrDnld))
4 changes: 2 additions & 2 deletions examples.py
@@ -1,8 +1,8 @@
from py3pin.Pinterest import Pinterest

pinterest = Pinterest(email='email',
password='pass',
username='username from settings',
password='password',
username='username',
cred_root='cred_root')

# to release
Expand Down
1 change: 1 addition & 0 deletions py3pin/Pinterest.py
Expand Up @@ -161,6 +161,7 @@ def login(self, headless=True, wait_time=15, proxy=None):
except Exception as e:
print("Failed to login", e)

print("Successfully logged in with account " + self.email)
driver.close()

def logout(self):
Expand Down
2 changes: 1 addition & 1 deletion py3pin/Registry.py
Expand Up @@ -15,7 +15,7 @@ def __init__(self, root, username):
shutil.rmtree(self._get_cred_file_path())

if not os.path.exists(root):
os.mkdir(root)
os.makedirs(root)

try:
with open(self._get_cred_file_path()) as f:
Expand Down
2 changes: 1 addition & 1 deletion py3pin/__version__.py
@@ -1 +1 @@
__version__ = '1.2.1'
__version__ = '1.2.2'

0 comments on commit ed8e6b3

Please sign in to comment.