Skip to content

Hi This is the repository where my pinterest automation is being builded So have fun while trying my bot

Notifications You must be signed in to change notification settings

Daniyal-prodev/Pinterest-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pinterest-bot

Windows 10 automation tool that:

  • Opens regular Google Chrome (default profile, not incognito)
  • Goes to https://www.pinterest.com/pin-creation-tool/
  • Speaks a prompt asking you to type:
    • ChatGPT prompt
    • Board name
    • Destination link
  • Uses OpenRouter OpenAI API to generate only useful data: Title, Description, Tags
  • Fills the fields on Pinterest, uploads a random image from your folder without repeating until all are used, selects the board, sets the link, and publishes
  • Repeats in a loop

Prerequisites

  • Windows 10 with Google Chrome installed
  • You are logged into Pinterest in Chrome’s Default profile
  • An OpenRouter API key
  • An images folder at Z:\family (or set IMAGES_DIR to your path)

Setup

  1. Create a .env file in the repo root:
# Prefer OPENROUTER_API_KEY; OPENAI_API_KEY is also accepted as a fallback
OPENROUTER_API_KEY=sk-or-...
# or:
# OPENAI_API_KEY=sk-or-...

OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
OPENROUTER_MODEL=openrouter/auto
IMAGES_DIR=Z:\family
# Delay between pins in seconds
RATE_LIMIT_SECONDS=8
  1. Install Python dependencies (optional if using the .exe):
pip install -r requirements.txt

Run from source

python -m pinterest_bot
  • The app will speak a message asking you to type your prompt, board name, and link.
  • If Chrome is not logged in to Pinterest, the bot will wait and automatically continue once your Chrome session becomes authenticated.
  • The tool will generate content, fill the fields, click image upload, wait ~10 seconds, upload a random non-repeated image from your images folder, select the board, set the link, and publish.
  • It will then ask if you want to run again.

Windows executable

Build locally on Windows 10 using PyInstaller:

  1. Install Python 3.12 (recommend adding to PATH).
  2. In a terminal at the repo root:
    • pip install -r requirements.txt
    • pip install pyinstaller
    • pyinstaller --onefile -n PinterestBot src/pinterest_bot/main.py
  3. The executable will be at dist/PinterestBot.exe.

Runtime:

  • Place a .env file next to PinterestBot.exe (or run from a folder that has .env) with your key and IMAGES_DIR.
  • Ensure Chrome is logged in on the Default profile.

Image reuse prevention

State is stored at %APPDATA%\PinterestBot\state.json. It tracks used image paths. When all images have been used, it resets and starts over.

Notes

  • Tags are comma-separated. If Pinterest’s tags input is not present, hashtags are appended at the end of the description.
  • This tool does not automate chat.openai.com; it uses the OpenRouter API.
  • The API key is loaded from .env and is not committed. It prefers OPENROUTER_API_KEY, but will also use OPENAI_API_KEY if present.

Troubleshooting

  • If selectors change on Pinterest, fields may not be found. Open an issue with details.
  • If you see login pages, complete login in the opened Chrome window; the bot will continue automatically once authenticated.

Robustness improvements

  • Automated login detection: the bot detects Pinterest login state without requiring console input. If not logged in, it waits until the session becomes authenticated.

  • Directory changes: the bot rescans the images directory on every run and prunes missing files from state. New images are discovered automatically; no repeats until all images are used.

  • API resilience: OpenRouter calls use retries with exponential backoff and strict JSON extraction with a fallback parser. Tags are sanitized to remove special characters.

  • Cross-platform paths: Windows paths are normalized; Chrome user data directories are selected per platform. State and logs live at %APPDATA%\PinterestBot on Windows.

  • Error logging: logs are written to %APPDATA%\PinterestBot\logs.txt and also printed to console.

  • Rate limiting: set RATE_LIMIT_SECONDS in .env to control delay between pins.

  • Input validation: destination URL and board name are validated before attempting to publish.

  • Improved selectors: more resilient Pinterest element selectors and longer, staged waits for dynamic UI.

  • If no images are found in your folder, set IMAGES_DIR to the correct path in .env.

About

Hi This is the repository where my pinterest automation is being builded So have fun while trying my bot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages