13

Jeff's blog post about digital sharecropping made me realize that my 800 answers on Stack Overflow contain some valuable content that I would like to repurpose. Can I download all my answers in machine-readable form? How?

If not, please consider this a feature request.

  • There's no way of retrieving answers if the question is deleted. From now on it might be best to backup your answers somewhere before you submit them. – Sam Hasler Aug 15 '09 at 16:19
  • 1
    Jeff: sorry to ask for a feature that's already been implemented. I seem to spend my SO time answering questions instead of reading the blog... – Norman Ramsey Aug 19 '09 at 19:17
  • 1
    not a problem, it's a perfectly reasonable question! – Jeff Atwood Aug 20 '09 at 3:55
  • 1
    Bump. So how do I download my StackOverflow content? – Colonel Panic Oct 18 '12 at 21:45
6

An alternative to using the SQL version of the data dump is to use the XML as provided directly in the data dump. Most platforms provide a streaming XML reader: all you've got to do is load posts.xml (IIRC - I don't have a dump handy), load it in a streaming manner and write out all the posts with the relevant owner ID to whatever file format you want. If you just want to write out the XML for the posts you own, you can just hold open a streaming XML writer and write the element - easy!

Depending on what you've got in terms of database connectivity etc, that may well be easier to do. Let me know if you want some C# code to do this.

  • I'm much happier with direct XML; thanks. Followup question at meta.stackexchange.com/questions/15545/…. BTW I haven't enough rep on meta to edit your answer, but since it's accepted maybe you could link the data dump directly? Thanks. – Norman Ramsey Aug 19 '09 at 19:38
  • Good suggestion, done. – Jon Skeet Aug 19 '09 at 20:30
9

You would have to use the data dump, and then you could do:

select * from posts where owneruserid = 41661

BAM, machine readable.

Of course, you can always get a preview using Ian Elliot's frakking awesome Sandbox.

4

Although I don't know how much use it would get, I do kind of like the idea of a potential "personal data dump" which would allow you get just a dump of all your own information, questions, answers, etc.

  • This is old, but with the data portability requirements of GDPR, maybe this suggestion could be revived, if it hasn't already (and I've missed it; that wouldn't be the first time)... – a CVn Feb 26 at 8:05
3

As an alternative to downloading the whole XML or SQL data dump, it's nowadays possible to use SEDE to find and download all your posts, and only your posts.

Here's a query I just wrote that returns the Markdown and HTML content of all posts by a given user, plus a bunch of other useful data (including a list of all user who have edited the post, to help with providing attribution for posts with multiple contributors).

To use it, just select the SE site you want to download your posts from (using the slightly awkward SEDE site selector), fill in your numeric user ID (as found in the URL of your user page on the selected site) and click "Run Query". Then click the "Download CSV" link and import the resulting CSV file into whatever program or database you like (or just save it as is).

(Trying to open the CSV file e.g. in Excel doesn't really seem to work properly, presumably because all the HTML and Markdown text in it confuses Excel's CSV parser. But Python's csv module, for example, parses it just fine.)

Of course, you can also use the query to peek at someone else's contributions. For example, here are all my posts to meta.SE. (Alas, it looks like trying to fetch all of Jon Skeet's posts to SO times out. I may need to optimize the query further.)


Update: I made a cross-site version of the query that returns all your posts on all Stack Exchange sites.

To use it, you need to enter your Stack Exchange network account ID, which you can find by going to https://stackexchange.com/ and clicking your avatar in the top bar (or by clicking the "Network Profile" link on your user page on any SE site) and copying the number from the URL. For example, my network profile URL is https://stackexchange.com/users/178805/ilmari-karonen, where "178805" is my network account ID. Entering that into the query currently gives me a list of 3,625 posts, totaling about 16 MB in CSV format.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .