Export solved codewars kata challenges to a text file.

Overview

Codewars Kata Exporter

Note:this is not totally my work.i've edited the project to make more easier and faster for me.you can find the original work here https://github.com/lucasbflopes/codewars-kata-exporter.


General Information

It relies on the BeautifulSoup module to parse the kata solutions from raw HTML, and also uses the very limited Codewars API to get each kata description.

Since the solutions in the solution's page are dynamically generated, it is necessary to keep scrolling down in order to be able to collect all of them. This task was facilitated by using Selenium to emulate this repetitive work for you.

After saving the HTML, the script will parse it and create a file structure like below, wherein the katas are separated by difficulty. For each folder representing a kata, there is a folder for each language you completed the problem. The kata description is placed inside the README.md file and the solution source code inside solution.[language_extension].

solutions/
├── 3-kyu
│   └── the-millionth-fibonacci-kata
│       └── python
│           ├── README.md
│           └── solution.py
├── 4-kyu
│   ├── matrix-determinant
│   │   └── python
│   │       ├── README.md
│   │       └── solution.py
│   └── strip-comments
│       └── python
│           ├── README.md
│           └── solution.py
└── 6-kyu
    └── parabolic-arc-length
        ├── javascript
        │   ├── README.md
        │   └── solution.js
        └── python
            ├── README.md
            └── solution.py

How to install

First off, you need to have Python 3 installed in your machine. Then install all python dependencies required:

$ pip3 install -r requirements.txt

To use Selenium you need to install a webdriver to interface with a specific browser. The browser I have chosen to use in the script was Firefox.


How to run

Before executing the script, it is necessary to fill some information in setup.json:

{
  "codewars": {
    "email": "[email protected]",   <------------ Your login email
    "password": "foo123",     <------------ Your login password
    "api_key": "foofoo"       <------------ Codewars API token. Can be found under your account settings
  },
  "download_folder": "./solutions", <------ Root directory wherein the katas will be placed
  "file_extensions": {              <------ The parser only finds the text, so in order to save a file
    "java": ".java",                        you need to provide a proper extension. Here I put some
    "python": ".py",                        extensions for some common languages. If yours is not here 
    "javascript": ".js",                    feel free to add.
    "c": ".c",                              
    "c++": ".cpp",                          OBS: If none is found for your language during runtime, the
    "c#": ".cs",                            script will leave it empty, i.e. just 'solution' instead of
    "perl": ".pl",                          'solution.js' in the case of JavaScript
    "php": ".php",
    "ruby": ".rb"
  },
  "reloads_in_browser": 100   <------------ # of attempts to reload the page while scrolling down. Each
}                                           attempt takes 2s, which is the time I deemed enough to load
                                            more katas. This is 'hacky' part I mentioned about. Feel free
                                            to fine-tune this value to suit you best

Now run the script responsible for fetching the HTML:

$ python fetch_source.py

A firefox window will open and then will start to automatically:

  1. log into your account;not necessary in my case.i've chosen to load my firefox profile where codewars is already logged in.
  2. go to your solutions page;
  3. scroll down and wait according to the value of reloads_in_browser in setup.json.

After finishing, the script will save the HTML in ./source.html

OBS: You can skip this step altogether if you prefer to download the HTML source manually. That being the case, it is not necessary to fill both email and password in setup.json.

Lastly, run the script responsible for parsing the HTML and creating the file structure:

$ python main.py

Done!

License

free to use.enjoy!

Owner
Oussama Ben Sassi
Computer Science student.I love developing software with Python.Always curious and ready to learn new technologies.
Oussama Ben Sassi
BaseCrack is a tool written in Python that can decode all alphanumeric base encoding schemes.

BaseCrack Decoder For Base Encoding Schemes BaseCrack is a tool written in Python that can decode all alphanumeric base encoding schemes. This tool ca

Mufeed VH 383 Dec 27, 2022
A Python3 script that simulates the user typing a text on their keyboard.

A Python3 script that simulates the user typing a text on their keyboard. (control the speed, randomness, rate of typos and more!)

Jose Gracia Berenguer 3 Feb 22, 2022
Fixes mojibake and other glitches in Unicode text, after the fact.

ftfy: fixes text for you print(fix_encoding("(ง'⌣')ง")) (ง'⌣')ง Full documentation: https://ftfy.readthedocs.org Testimonials “My life is li

Luminoso Technologies, Inc. 3.4k Jan 08, 2023
strbind - lapidary text converter for translate an text file to the C-style string

strbind strbind - lapidary text converter for translate an text file to the C-style string. My motivation is fast adding large text chunks to the C co

Mihail Zaytsev 1 Oct 22, 2021
Simple python program to auto credit your code, text, book, whatever!

Credit Simple python program to auto credit your code, text, book, whatever! Setup First change credit_text to whatever text you would like to credit

Hashm 1 Jan 29, 2022
This is REST-API for Indonesian Text Summarization using Non-Negative Matrix Factorization for the algorithm to summarize documents and FastAPI for the framework.

Indonesian Text Summarization Using FastAPI This is REST-API for Indonesian Text Summarization using Non-Negative Matrix Factorization for the algorit

Viqi Nurhaqiqi 2 Nov 03, 2022
A minimal code sceleton for a textadveture parser written in python.

Textadventure sceleton written in python Use with a map file generated on https://www.trizbort.io Use the following Sockets for walking directions: n

1 Jan 06, 2022
Format Covid values to ASCII-Table (Only for Germany and Austria)

Covid-19-Formatter (Only for Germany and Austria) Dieses Script speichert die gemeldeten Daten des RKIs / BMSGPK und formatiert diese zu einer Asci Ta

56 Jan 22, 2022
A slugifier that works in unicode

Unicode Slugify Unicode Slugify is a slugifier that generates unicode slugs. It was originally used in the Firefox Add-ons web site to generate slugs

Mozilla 315 Nov 21, 2022
A production-ready pipeline for text mining and subject indexing

A production-ready pipeline for text mining and subject indexing

UF Open Source Club 12 Nov 06, 2022
Paranoid text spacing in Python

pangu.py Paranoid text spacing for good readability, to automatically insert whitespace between CJK (Chinese, Japanese, Korean) and half-width charact

Vinta Chen 194 Nov 19, 2022
Umamusume story patcher with python

umamusume-story-patcher How to use Go to your umamusume folder, usually C:\Users\user\AppData\LocalLow\Cygames\umamusume Make a mods folder and clon

8 May 07, 2022
A Python library that provides an easy way to identify devices like mobile phones, tablets and their capabilities by parsing (browser) user agent strings.

Python User Agents user_agents is a Python library that provides an easy way to identify/detect devices like mobile phones, tablets and their capabili

Selwin Ong 1.3k Dec 22, 2022
Python tool to make adding to your armory spreadsheet armory less of a pain.

Python tool to make adding to your armory spreadsheet armory slightly less of a pain by creating a CSV to simply copy and paste.

1 Oct 20, 2021
PyMultiDictionary is a Dictionary Module for Python 3+ to get meanings, translations, synonyms and antonyms of words in 20 different languages

PyMultiDictionary PyMultiDictionary is a Dictionary Module for Python 3+ to get meanings, translations, synonyms and antonyms of words in 20 different

Pablo Pizarro R. 19 Dec 26, 2022
Migrates translations to the REDCap native Multi-Language Management system

Automates much of the process of moving translations from the old Multilingual external module to the newer built-in Multi-Language Management (MLM) page.

UCI MIND 3 Sep 27, 2022
Goblin-sim - Procedural fantasy world generator

goblin-sim This project is an attempt to create a procedural goblin fantasy worl

3 May 18, 2022
a python package that lets you add custom colors and text formatting to your scripts in a very easy way!

colormate Python script text formatting package What is colormate? colormate is a python library that lets you add text formatting to your scripts, it

Rodrigo 2 Dec 14, 2022
A working (ish) python script to convert text to a gradient.

verticle-horiontal-gradient-script A working (ish) python script to convert text to a gradient. This script is poorly made with the well known python

prmze 1 Feb 20, 2022
box is a text-based visual programming language inspired by Unreal Engine Blueprint function graphs.

Box is a text-based visual programming language inspired by Unreal Engine blueprint function graphs. $ cat factorial.box ┌─ƒ(Factorial)───┐

Pranav 104 Dec 24, 2022