HubSpot does not provide for a global search and replace for its blog so it becomes a real pain if you need to make mass updates.
This simple python script attempts to fix the lack of a global search/replace by doing the following:
- for given blog id, get a list of all posts
- pull down the components of each post
- do the search/replace across all relevant components (title, url, body, rss body, etc.)
- push updated components back to HubSpot through their API
Fair Warning(s):
- This is not elegant code by any means. I needed something quick and I am not a developer. Any recommendations to make this more efficient are welcome!
- This script was built and tested on MacOS. If you're using another system, your mileage may vary.
- Make sure Python 2.7.x is installed on your system.
- Open up the file and change the following variables:
api_key
blog_id
string_to_replace
replacement_string
- Run the script in a terminal that supports colors and utf-8 characters
- Requires that the Python
requests
package is installed