Skip to content

A Python application that automatically pins images from Shutterstock to a Pinterest board. This application is designed to scrape images from a specified Shutterstock user collection and automatically add them to your Pinterest account.

License

Notifications You must be signed in to change notification settings

barisariburnu/python-shutterstock-pinner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shutterstock Pinner

A Python application that automatically pins images from Shutterstock to a Pinterest board. This application is designed to scrape images from a specified Shutterstock user collection and automatically add them to your Pinterest account.

Features

  • Automated image scraping and pinning to Pinterest
  • Database tracking to prevent duplicate pins
  • Random user agent usage
  • Error tolerance and automatic retry mechanism
  • Configurable sleep times
  • Modular and extensible code structure

Prerequisites

  • Python 3.7 or higher
  • Pinterest account
  • Internet connection

Installation

  1. Clone the repository:
git clone https://github.com/barisariburnu/python-shutterstock-pinner.git
cd python-shutterstock-pinner
  1. Install the required dependencies:
pip install -r requirements.txt

Configuration

Before using the application, fill in your credentials in the config.py file:

PINTEREST_EMAIL = 'your_pinterest_email@example.com'
PINTEREST_USERNAME = 'your_pinterest_username'
PINTEREST_PASSWORD = 'your_pinterest_password'

PINTEREST_BOARD_ID = 'your_board_id'

SHUTTERSTOCK_USERNAME = 'your_shutterstock_username'
SHUTTERSTOCK_SORT_BY = 'popular'  # 'popular' or 'newest'

SLEEP_TIME = 420  # Time between pins (in seconds)
MAX_RETRIES = 3    # Maximum retry attempts
RETRY_DELAY = 60   # Delay between retries (in seconds)
MAX_PAGES = 100    # Maximum pages to scrape

Finding Your Pinterest Board ID

  1. Log in to your Pinterest account
  2. Click on the board you want to use
  3. Copy the ID from the URL: https://pinterest.com/username/board-name/ → The ID may be in the URL or can be obtained via API

Usage

Run the application with:

python main.py

The application performs the following steps:

  1. Logs into Pinterest
  2. Starts scraping the Shutterstock collection (default: 100 pages)
  3. Scans each page for images
  4. Pins previously unpinned images to Pinterest
  5. Waits for the configured time after each operation
  6. Retries after 60 seconds on error

Project Structure

python-shutterstock-pinner/
├── config.py              # Configuration file
├── main.py                # Main application file
├── requirements.txt       # Python dependencies
├── create_sample_db.py    # Sample database generator
├── models/
│   ├── __init__.py
│   ├── pinterest.py       # Pinterest API wrapper
│   ├── shutterstock.py    # Shutterstock scraper
│   └── user_agents.py     # User agent list
├── tests/                 # Unit tests
│   ├── test_main.py
│   ├── test_pinterest.py
│   └── test_shutterstock.py
├── database/              # Database files
└── data/                  # Pinterest credentials (auto-generated)

Database

The application uses pickledb to track pinned images. The database file is created at database/board_{PINTEREST_BOARD_ID}.db. This prevents the same image from being pinned twice.

Running Tests

The project includes comprehensive unit tests. Run them with:

pytest tests/ -v

Creating a Sample Database

You can create a sample database for testing purposes:

python create_sample_db.py

This creates a sample database at database/board_1234567890123456789.db with test data.

Dependencies

  • requests~=2.25.1 - For HTTP requests
  • beautifulsoup4~=4.9.3 - For HTML parsing
  • py3-pinterest~=1.2.2 - Pinterest API wrapper
  • pickledb~=0.9.2 - For simple database operations

Important Notes

  • This application is for educational and personal use only.
  • Compliance with Shutterstock and Pinterest's terms of service is your responsibility.
  • Automatic pinning may cause your account to be flagged as spam. Adjust the SLEEP_TIME parameter to reduce this risk.
  • Be careful to only pin publicly available and properly licensed images.
  • Always respect copyright laws and licensing terms.

Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

For more detailed contribution guidelines, see CONTRIBUTING.md.

Testing

The project includes unit tests for all major components:

# Run all tests
pytest tests/ -v

# Run specific test file
pytest tests/test_main.py -v

# Run specific test
pytest tests/test_main.py::TestMain::test_parse_image_url -v

Code Style

We follow PEP 8 style guidelines. Please ensure your code adheres to these standards before submitting pull requests.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Disclaimer

This software is provided "as is", without warranty of any kind. The authors or contributors are not responsible for any damages resulting from the use of this software.

Support

If you encounter issues or have suggestions, please open an issue.

License and Copyright

  • Copyright of Shutterstock images used in this project may belong to Shutterstock.
  • Users are expected to respect copyright laws and use only properly licensed images.

About

A Python application that automatically pins images from Shutterstock to a Pinterest board. This application is designed to scrape images from a specified Shutterstock user collection and automatically add them to your Pinterest account.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages