Setting Up Automated Blog Posting with Selenium Saves You 1 Hour a Day
I'll be honest. At first, I was spending 15–20 minutes just to publish a single blog post. Logging in, choosing a category, adding tags, hitting the publish button… I got so tired of this repetitive work that I went looking for a solution, and that's when I discovered Selenium automation. After reading this post, even if you only know a little Python, you'll be able to build the basic structure for automating your blog posting right away.
① Install This First — Environment Setup Takes Just 5 Minutes
To use Selenium, you only need two things: Python and a Chrome driver. A lot of beginners get stuck right here, but if you just follow the steps in order, you'll be done in under 5 minutes.
- Install Python: Download the latest version from python.org and install it. Make sure to check the "Add Python to PATH" checkbox during installation. Skipping this will cause headaches later.
- Install Selenium: In your terminal (cmd on Windows), just type
pip install seleniumand you're done. - Install webdriver-manager: Also install
pip install webdriver-manager. It automatically handles matching the Chrome driver version, which makes things much easier.
Once installation is complete, create a Python file and if the code below runs without errors, your setup is complete.
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("https://www.google.com")
print("Setup complete!")
If a Chrome window opens and Google loads, you're successful. If you've made it this far, you're halfway there.
② Login Automation — Understand This Code Structure and You Can Apply It Anywhere
The core of Selenium is "using code to perform the actions a person would do in a browser." Clicking, typing text, pressing buttons — if you can do just these three things, you can automate login.
Let me give you an example using Tistory. The flow is: find the ID input field, click it, type the ID, enter the password, and click the login button.
from selenium.webdriver.common.by import By
import time
driver.get("https://www.tistory.com/auth/login")
time.sleep(2)
# Click the login with Kakao account button
driver.find_element(By.CLASS_NAME, "kakao_link").click()
time.sleep(2)
# Enter Kakao ID/password
driver.find_element(By.ID, "loginId--1").send_keys("my ID")
driver.find_element(By.ID, "password--2").send_keys("my password")
driver.find_element(By.CLASS_NAME, "btn_g.highlight.submit").click()
time.sleep(3)
Pro tip! When you're confused about finding an element, open F12 (Developer Tools) in Chrome → Select element → Click with your mouse, and the ID or class name of that element will appear right away. Just copy and paste it into your code. It might feel unfamiliar at first, but after 2–3 tries you'll get used to it quickly.
However, some sites block automation with enhanced security, so if your login keeps getting rejected, there's also a workaround using cookie-saving methods. (I'll cover that in a future post.)
③ Automated Post Writing & Publishing — This Is the Real Core Part
Now that you're logged in, here's the main part. This is where we automate entering the post title, adding the body content, tagging, and clicking the publish button. The moment this works, you'll feel like, "Wow, this is actually real."
After navigating to the post creation page, the approach is to find each input field and insert the content.
# Navigate to the post writing page
driver.get("https://myblogaddress.tistory.com/manage/post/")
time.sleep(2)
# Enter the title
title_input = driver.find_element(By.CSS_SELECTOR, "input[placeholder='Enter a title']")
title_input.click()
title_input.send_keys("Today's Auto Post Title")
# Enter the body (may require iframe switch)
driver.switch_to.frame("editor-content-iframe") # iframe name varies by site
body = driver.find_element(By.TAG_NAME, "body")
body.send_keys("The body content goes here.")
driver.switch_to.default_content()
# Click the publish button
driver.find_element(By.CSS_SELECTOR, "button.btn-publish").click()
time.sleep(2)
There's something important to note. The editors on Tistory and Naver Blog often have the body input field inside an iframe. So you need to use switch_to.frame() to enter the iframe first, then type the text. A lot of people get stuck here, but you can check the iframe name using the developer tools.
Also, time.sleep() may seem tedious, but you absolutely must include it. If the next line of code runs before the page finishes loading, you'll get an error. Once you get more comfortable, you can handle wait times more smartly using WebDriverWait.
④ Repeated Posting Automation — Upload Multiple Posts at Once with a Single CSV File
Now that you've come this far, it's time to experience the true taste of automation. Instead of publishing one post at a time, the idea is to prepare a list of posts in a CSV file in advance and upload multiple posts in a row all at once.
The method is simple. Organize your content in Excel or Google Sheets like this:
- Column A: Title
- Column B: Body content
- Column C: Tags
- Column D: Publish status (Y/N)
Then in Python, use pandas to read the CSV and post in a loop.
import pandas as pd
df = pd.read_csv("posts.csv")
for index, row in df.iterrows():
if row['PublishStatus'] == 'Y':
# Call the posting function created above
post_blog(driver, row['Title'], row['Body'], row['Tags'])
time.sleep(5) # Add a delay between consecutive posts
print(f"{row['Title']} published successfully!")
This has the same effect as writing 10 posts in advance and scheduling them all to publish with a single button. I personally write 5–7 posts on the weekend and have them set to automatically go up Monday through Friday in the morning. If you want to add a scheduler, use Task Scheduler on Windows or crontab on Mac/Linux.
Of course, it's not perfect. If the site's UI changes, you'll need to re-identify the selectors, and if a CAPTCHA appears, you may need to solve it manually. Even so, reducing 80% of repetitive work is a certainty.
Just Try This One Thing Right Now
Even though today's content might seem like a lot, the core is actually simple. For right now, just try one single thing.
→ Install Python and Selenium, and run the code that automatically opens Chrome just once
If you succeed at just this one thing, everything else will follow. The most important thing is to see with your own eyes that "this actually works." If you get stuck during installation, leave a comment. I've encountered almost every error out there and can help you work through them together.
Automation isn't something grand. It's about reclaiming your own time from repetitive tasks. Just invest 30 minutes today and give it a try.
댓글
댓글 쓰기