Downloading Your Old LiveJournal

Download your entire LiveJournal at once rather than month by month.

Downloading Your Old LiveJournal

Oh no, LiveJournal emailed me to tell me I had a 19 year anniversary. I had to ask myself, do I just delete this thing outright, or back it up first? Well, maybe there are some things in there I'd want to revisit at some point. It was a matter of how much effort that would be since they don't make it easy. Well, I was able to make it easy enough.

Unfortunately, I didn't take any screenshots before I hacked my way through this. But let's talk about it a little bit.

https://www.livejournal.com/export_do.bml is the page you want to go to. Go to More Tools > Web Developer Tools in Firefox to get things ready. Fill out the form one time and submit. Go to the Network tab in the dev tools pane to start gathering info. You'll want the POST entry you just made. Copy everything from Headers and Cookies.

Once you have everything you need, take the code below, populate it with the information described in the comments, and it should download each month's worth of journal entries to a separate XML file. You'll need the Requests library.

#!/usr/bin/python3

import requests

# Your username after 'authas'
url = "https://www.livejournal.com/export_do.bml?authas=superzapper"

# Gather all the LJ cookies from your browser, make them a dictionary.
cookies = {
    "ab_d": "",
    "addruid": "",
    "adtech_uid": "",
    "bltsr": "",
    "BMLschemepref": "",
    "langpref": "",
    "lj_sale_adblock": "",
    "ljloggedin": "",
    "ljmastersession": "",
    "ljsession": "",
    "ljuniq": "",
    "luid": "",
    "prop_password_change_refusal": "",
    "sspjs_38.16.0_af_lpdid": '',
}

headers = {
	# Match the user-agent to the request header your browser used to get you here.
    "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
    "Accept-Language": "en-US,en;q=0.5",
    "Referer": "https://www.livejournal.com/export.bml",
    "Content-Type": "application/x-www-form-urlencoded",
    "Cookie": r"yourcookiestuffhere", # You'll see a cookie string in your header. Maybe redundant?
}

data = {
    "authas": "yourusername", # replace with your username, maybe redundant?
    "what": "journal",
    "format": "xml",
    "header": "on",
    "encid": "2",
    "field_itemid": "on",
    "field_eventtime": "on",
    "field_logtime": "on",
    "field_subject": "on",
    "field_event": "on",
    "field_security": "on",
    "field_allowmask": "on",
    "field_currents": "on",
}

# Year you started, year you ended +1
for i in range(2003, 2014):
    for j in range (1,13):
        year = str(i)
        month = "{:02d}".format(j)
        data["year"] = year
        data["month"] = month
        r = requests.post(url, data=data, headers=headers, cookies=cookies)
        if "<entry>" in r.text:
            with open(f"livejournal_{year}_{month}.xml", "w") as f:
                f.write(r.text)