9

All the answers that I published here demanded many hours of invested time, and I figured that if I wanted to carry out many of those actions today, I would need reminders about exact details.

Until now, I could always return to my AskUbuntu account for this purpose, and find the info here. Perhaps that can stay like that in the future as well.

However, these days' developments inspired me to download all the content that I produced on this site (answers and questions), preferably in their original markdown format.

I know SE offers some APIs, but I never invested time in learning about them, and SQL is not my forte either.

Is it possible to fetch all my answers and questions from some interface with some straightforward query?

Could you please explain how to do that?

(Bonus: in case of my questions, I would like to save the answers that I received from others, as well.)

3

1 Answer 1

4

There is a SEDE query that allows you to do exactly that: All my posts on the SE network (with Markdown and HTML content plus editors and status)

You can use it to download a CSV with all your posts along the Stack Exchange network as follows:

  1. Go to your profile page → ProfilesNetwork profile, as shown in the screenshot below:

    Profile page

  2. Copy your SE network account ID, found in the URL, as shown in the screenshot below:

    Network profile page

  3. Open the SEDE query, paste your ID in the Enter Parameters textbox, and press Run query (you may need to solve a Captcha):

    SEDE query page

  4. This will show all your posts in a table, similar to the one below:

    SEDE query results table

  5. You can save the results in a CSV file by clicking Download CSV (also shown in the above screenshot).


If you wish to edit the downloaded CSV, the simplest way is to use LibreOffice Calc:

  1. right-click on the downloaded file → Open With...LibreOffice CalcOpen.

  2. In the window that opens check Comma under Separator Options and then click OK.

    LibreOffice Calc import window

  3. That's it! You should now have your results in a spreadsheet similar to the following:

    Results in LibreOffice Calc

10
  • It's nice to see the detailed steps, like your answers on the main site ;) Commented Jun 6, 2023 at 18:33
  • 1
    Thanks @RandomPerson ! :) Commented Jun 6, 2023 at 19:33
  • My only grief is with LibreOffice (6.4): I am interested most in the markdown column, but when LibreOffice opens, the markdown column is the only one that's squished to a 0.3cm width, practically unnoticable, while the cells containing the HTML are so huge (exceeding my screen dimension) that I cannot properly scroll the content: scrolling, in each direction, consistently jumps over specific content. Zooming out helps somewhat. Otherwise I can open the CSV in Gedit, and search for specific words I remember to have used.
    – Levente
    Commented Jun 6, 2023 at 21:16
  • 1
    @levente If you adjust the columns as you like with Calc and then save the file as.ods, the columns should remain as you've set them. Commented Jun 7, 2023 at 5:12
  • Is there a way to copy and save all selected .htm's at once? , not just links? So they are located on my computer, Commented Jun 7, 2023 at 10:07
  • @C.S.Cameron You can use wget for each link in the CSV to download the entire webpage of each post. I tried to make a script to automate it, but got temporarily blocked for making too many requests (oops!). Perhaps a delay could be used between each wget request to avoid throttling, but I'm not sure what that delay should be and if it would indeed work, so I'm not risking it. Commented Jun 7, 2023 at 12:28
  • The CSV is nice but I would also like to copy the pictures. like when I do a Save link as > XXXXXXX.htm Commented Jun 7, 2023 at 12:38
  • @C.S.Cameron The HTML and Markdown columns already include the imgur links of your posts' images. So the images are there in essence. You can use the items of the HTML column to save your posts in pure HTML. You can use this simple Python script (that depends on pandas (sudo apt install python3-pandas )) I created to save all posts as HTML files in the folder you run the script from. You can find the script here: pastebin.com/veBEa5Aa Just change the path to your downloaded CSV in the csv_path variable and then run the script using python script.py. Commented Jun 7, 2023 at 13:30
  • Pictures remaining on Imgur are as safe as "owning" pictures as NFTs :P
    – Levente
    Commented Jun 7, 2023 at 18:35
  • So I just need to download the pictures separately. This is Okay as long as Imgur is working. Commented Jun 8, 2023 at 2:43

You must log in to answer this question.

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