Bookmarks2Notion is a script designed to import your browser bookmarks into Notion. Using a combination of web scraping and OpenAI API, it creates a new page in your Notion database for each bookmarked URL, allowing you to easily organize and access your bookmarks in one central location.
- Screenshots
- Prerequisites
- How to run
- Environment variables
- How to get required API key values
- License
- About developer
Script running:
Pages created in the Notion DB
Generated page content (includes direct link, title, and description enriched with AI)
In order to run this script, you will need:
- Python 3.8 or higher
- A Notion account
- An OpenAI account
- The bookmarks file you want to import into Notion (compatible with any text format: *.txt, *.html, etc)
- Rename
.env.template
to.env
- Inside
.env
set the value to environment variables (How to do that?) - Add your URL's inside the file you specified. (default is bookmarks.txt)
- Install the required Python packages using pip.
pip install -r requirements.txt
- Run the script:
py main.py
The script will read the URLs from the bookmarks file, scrape each web page, process the scraped information, and create a new page in your Notion DB.
BOOKMARKS_FILE
: Relative path to your bookmarks file. (Required)OPENAI_API_KEY
: Your OpenAI's API. (Required)NOTION_API_KEY
: Your Notion's API. (Required)NOTION_DB_ID
: The ID of the Notion database where the pages will be created. (Required)USER_AGENT
: The User-Agent header value to be used when making HTTP requests. (Optional)LANGUAGE
: The language to be used when processing the scraped information with OpenAI's language model. (Optional)
Note: Instructions on how to get the API key values and database ID can be found in the How to get required API key values section.
Instructions to get required API key values:
To generate an OpenAI API key, follow these steps:
- Go directly to OpenAI API keys section: https://platform.openai.com/api-keys) (You must be logged in)
- Click on "Create new secret key"
- Now you can choose a name, after that click on "Create secret key"
- That's it, now you got the value for OPENAI_API_KEY
Note: You may need to provide additional information or complete additional steps to verify your identity or payment information before you can generate an API key.
To generate a Notion API key, follow these steps:
- Go to my integrations page: https://www.notion.com/my-integrations (You must be logged in)
- Click on 'Create new integration'
- Fill this form and click 'Submit'
- Now here is your Notion API key, click on 'Show' and copy it!
- Congrats, now you got the value for NOTION_API_KEY.
To find the Notion database ID, follow these steps:
- Go to the Notion website (https://www.notion.com/).
- Log in to your account.
- Create a new database
- Give access to Bookmarks-to-Notion integration. Just click three dots icon -> Connect to -> Bookmarks-to-Notion
- Click on 'Share' and click on 'Copy link' button.
- Paste the link into a text editor or a web browser.
- Look for the string of characters between the last two slashes in the URL. This is the database ID.
- Copy the database ID and you got the value for NOTION_DB_ID.
This project is released under the MIT License.
Visit my web Carlos Ochoa
Note: If you encounter any issues with the script, please report them here. Contributions are welcome!