Skip to content

kinpoe-ray/Chrome-Screenshot-to-Notion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stars Forks Discussion posts Static Badge License

README in English 简体中文版自述文件 follow on Twitter

Chrome Screenshot to Notion

This script automatically takes screenshots of web pages and uploads them to a specific Notion database page. It works with Notion's API and uses Selenium for web crawling and Cloudinary for external image serving.
How I achieved it with no programming basics »

View Demo · Report Bug · Request Feature

About The Project

AIGC bookmarks

Favorite Tools

Built With

This project utilizes several key Python libraries and frameworks:

Selenium: Used for web scraping and taking screenshots of web pages.

Cloudinary: Provides cloud-based image hosting services.

Requests: Used for making HTTP requests to the Notion API.

webdriver_manager: Simplifies the management of ChromeDriver for Selenium.

json: Used for parsing and creating JSON data.

logging: Provides a flexible framework for generating log messages.

base64: Used for encoding and decoding the screenshot data.

time: Used for adding delays and handling timeouts.

All coding driven by AI. ( Claude , ChatGPT , Mistral )

Features

  • Fetches pages from a specified Notion database
  • Takes screenshots of URLs found in the database pages
  • Uploads screenshots to Cloudinary
  • Updates Notion pages with the screenshot URLs
  • Implements retry logic and error handling
  • Tracks processed URLs to avoid duplicates

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

  • Python 3.7+
  • Chrome browser
  • Notion API key
  • Cloudinary account

Installation

  1. Clone this repository:

    git clone https://github.com/kinpoe-ray/chrome-screenshot-to-notion
    cd chrome-screenshot-to-notion
    
  2. Install required packages:

    pip install -r requirements.txt
    
  3. Install ChromeDriver (if not already installed):

    pip install webdriver_manager
    

Configuration

  1. Open the script and update the following variables:

    • notion_api_key: Your Notion API key
    • database_id: The ID of your Notion database
    • Cloudinary configuration in the upload_to_image_hosting_service function
      • cloud_name: Your user name
      • api_key: Your API key
      • api_secret: Your API secret
  2. Adjust the max_screenshots variable if needed (default is 50)

Usage

Run the script with:

python chrome-screenshot-to-notion.py

The script will:

  1. Fetch pages from the specified Notion database
  2. Take screenshots of URLs found in the pages
  3. Upload screenshots to Cloudinary
  4. Update Notion pages with the screenshot URLs

Logging

The script logs its progress and any errors to the console. You can adjust the logging level in the script if needed.

Error Handling

  • The script implements retry logic for API calls
  • It uses exponential backoff for failed attempts
  • Processed URLs are saved to avoid duplicates even if the script is interrupted

Limitations

  • The script is set to run headless. Modify Chrome options if you need to see the browser while running
  • It's designed to work with specific Notion page properties ('file' and 'url'). Adjust as needed for your database structure

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your 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

Top contributors

contrib.rocks image

License

MIT License

Releases

No releases published

Packages

No packages published

Languages