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
Fuzzy string matching like a boss. It uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package.

Fuzzy string matching like a boss. It uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package.

SeatGeek 1.2k Jan 01, 2023
🍋 A Python package to process food

Pyfood is a simple Python package to process food, in different languages. Pyfood's ambition is to be the go-to library to deal with food, recipes, on

Local Seasonal 8 Apr 04, 2022
Making simplex testing clean and simple

Making Simplex Project Testing - Clean and Simple What does this repo do? It organizes the python stack for the coding project What do I need to do in

Mohit Mahajan 1 Jan 30, 2022
Python Lex-Yacc

PLY (Python Lex-Yacc) Copyright (C) 2001-2020 David M. Beazley (Dabeaz LLC) All rights reserved. Redistribution and use in source and binary forms, wi

David Beazley 2.4k Dec 31, 2022
The Levenshtein Python C extension module contains functions for fast computation of Levenshtein distance and string similarity

Contents Maintainer wanted Introduction Installation Documentation License History Source code Authors Maintainer wanted I am looking for a new mainta

Antti Haapala 1.2k Dec 16, 2022
Split large XML files into smaller ones for easy upload

Split large XML files into smaller ones for easy upload. Works for WordPress Posts Import and other XML files.

Joseph Adediji 1 Jan 30, 2022
Convert English text to IPA using the toPhonetic

Installation: Windows python -m pip install text2ipa macOS sudo pip3 install text2ipa Linux pip install text2ipa Features Convert English text to I

Joseph Quang 3 Jun 14, 2022
This script has been created in order to find what are the most common demanded technologies in Data Engineering field.

This is a Python script that given a whole corpus of job descriptions and a file with keywords it extracts the number of number of ocurrences of these keywords and write it to a file. This script it

Antonio Bri Pérez 0 Jul 17, 2022
A program that looks through entered text and replaces certain commands with mathematical symbols

TextToSymbolConverter A program that looks through entered text and replaces certain commands with mathematical symbols Example: Syntax: Enter text in

1 Jan 02, 2022
This is a text summarizing tool written in Python

Summarize Written by: Ling Li Ya This is a text summarizing tool written in Python. User Guide Some things to note: The application is accessible here

Marcus Lee 2 Feb 18, 2022
Um simulador de caixa registradora com database usando arquivos .txt

🛒 Caixa Registradora V2 ❓ - Como usar? Execute o caixa-registradora.py, nele vai ter um menu interativo, você pode cadastrar diversos produtos em um

Gabriel 0 Sep 25, 2022
Map Reduce Wordcount in Python using gRPC

This project is implemented in Python using gRPC. The input files are given in .txt format and the word count operation is performed.

Divija 4 Dec 05, 2022
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
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
Free & simple way to encipher text

VenSipher VenSipher is a free medium through which text can be enciphered. It can convert any text into an unrecognizable secret text that can only be

3 Jan 28, 2022
Maiden & Spell community player ranking based on tournament data.

MnSRank Maiden & Spell community player ranking based on tournament data. Why? 2021 just ended and this seemed like a cool idea. Elo doesn't work well

Jonathan Lee 1 Apr 20, 2022
You can encode and decode base85, ascii85, base64, base32, and base16 with this tool.

You can encode and decode base85, ascii85, base64, base32, and base16 with this tool.

8 Dec 20, 2022
PyNews 📰 Simple newsletter made with python 🐍🗞️

PyNews 📰 Simple newsletter made with python Install dependencies This project has some dependencies (see requirements.txt) that are not included in t

Luciano Felix 4 Aug 21, 2022
Amazing GitHub Template - Sane defaults for your next project!

🚀 Useful README.md, LICENSE, CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md, GitHub Issues and Pull Requests and Actions templates to jumpstart your projects.

276 Jan 01, 2023
An online markdown resume template project, based on pywebio

An online markdown resume template project, based on pywebio

极简XksA 5 Nov 10, 2022