DEV Community

Jeffrey.Feillp
Jeffrey.Feillp

Posted on

I Wrote a Python Script That Batch-Publishes to Dev.to — Here's the Code

I Wrote a Python Script That Batch-Publishes to Dev.to

If you're a technical writer who publishes on Dev.to regularly, you know the ritual:

  1. Click "New Post"
  2. Choose your editor
  3. Paste markdown
  4. Set title and tags
  5. Hit Publish
  6. Repeat for the next article...

I got tired of this after publishing a 4-article series. So I automated it.

The Script

import requests, re

s = requests.Session()
s.headers['User-Agent'] = 'Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36'

# Login
r = s.get('https://dev.to/enter')
csrf = re.search(r'authenticity_token.*?value="([^"]+)"', r.text).group(1)
s.post('https://dev.to/users/sign_in', data={
    'user[email]': EMAIL, 'user[password]': PASS,
    'authenticity_token': csrf, 'user[remember_me]': '1',
})

# Get CSRF for article creation
r = s.get('https://dev.to/new')
csrf = re.search(r'authenticity_token.*?value="([^"]+)"', r.text).group(1)

# Publish
s.post('https://dev.to/articles', data={
    'authenticity_token': csrf,
    'article[title]': 'My Article Title',
    'article[body_markdown]': open('article.md').read(),
    'article[tags]': 'python,devto',
    'article[published]': '1',
})
Enter fullscreen mode Exit fullscreen mode

That's the core. The full version handles error recovery, rate limiting, batch processing, and session persistence.

What I Learned

Dev.to's CSRF system is interesting. The authenticity token on the dashboard works for article creation — you don't need to parse the /new page.

Rate limiting is about 1 post per 30 seconds. The script auto-waits between publishes.

Get the Full Version

I packaged everything into a complete tool:

  • Batch publish — point at a folder of .md files
  • YAML frontmatter — auto-parses title, tags, series
  • Session persistence — reuses login across runs
  • Error handling — retries on failure, logs everything
  • Draft support — preview before publishing live

$15 USDT (TRC-20) — one-time purchase, no subscription.

TNeUMpbwWFcv6v7tYHmkFkE7gC5eWzqbrs
Enter fullscreen mode Exit fullscreen mode

Product page with full details:
https://telegra.ph/Devto-Batch-Publisher--15-USDT-One-Time-Purchase-04-29

After payment, message me on Telegram (@tianka_ai) with the transaction hash.


Built with Python 3, requests, and a bit of patience with CSRF tokens.

Top comments (1)

Collapse
 
3969129510 profile image
Jeffrey.Feillp

I built this tool because I was tired of manually publishing each article. It saves me about 30 minutes every time I publish a series.