[PYTHON] Migrate Qiita articles to GitHub

Introduction

I think that relying on one service is a risk, so I will write a script to migrate Qiita articles to GitHub.

In addition, my article is as follows. https://github.com/mima3/note

(Added on 2020/3/29) Please refer to the following for the migration to WordPress. https://qiita.com/mima_ita/items/f4beb31c0ba65e6ab409

Operating environment

Python 3.7.4 Windows10

Advance preparation

Get the Qiita access token.

(1) Click "Issue a new token" from the application tab of the setting screen.

image.png

(2) Give read permission and press "Publish" image.png

(3) Make a note of the access token image.png

how to use

(1) Get the script from the following repository https://github.com/mima3/qiita_exporter

(2) Execute the script in the following format.

python qiita_to_github.py [userid] [accesstoken] [Save destination folder] [GitHub blob root URL ex.https://github.com/mima3/note/blob/master]

(3) Register the save destination folder on GitHub.

What you are doing

-Use Qiita API to get all the markdown described by the specified user on Qiita. -Download the image locally and rewrite the link. -On lines other than the code block, add a space 2 before the line feed code to start a new line. ・ If there is a description of "#title", change it to "#title". -Code block title (eg ""```python:test.py ") is not displayed, so respond. ・ Modify the URL to your article to the URL of the migration destination

#Task ・ What to do with expressions such as tags. ・ How do you handle comments? -The title is the file name, but it does not work depending on the characters used. Depending on the title, it may be necessary to convert it to uppercase. ・ Maybe it's better to use the Wiki function. .. .. -Twitter embedding that could be displayed on Qiita is not displayed properly. image.pngimage.pngGitHub PagesThere is a markdown where Jekyll doesn't work. For example{%s}It will fail if the code is mixed. image.png

image.png

Recommended Posts

Migrate Qiita articles to GitHub
Migrate Qiita articles to GitHub Pages + VuePress
Migrate Qiita articles to WordPress
Back up Qiita posts to GitHub
Migrate Qiita stock and LGTM to "Hatena Bookmark"
[First API] Try to get Qiita articles with Python
Scraping your Qiita articles to create a word cloud
Convert Qiita articles to Jekyll post format for backup
Migrate from requirements.txt to pipenv
Cannot migrate from direct_to_template to TemplateView
Migrate from VS Code to PyCharm