Giter VIP home page Giter VIP logo

coderetriever's Introduction

Code Retriever

A simple tool to download source code of SPOJ and Codeforces submissions including both regular and gym contests.

Features

  • Download all accepted SPOJ submissions (requires spoj user and password)

  • Download all accepted Codeforces submissions of a user (can use any handle)

  • Download all accepted Codeforces gym submissions (requires your codeforces password)

  • If there are multiple accepted submissions for a problem, the last accepted submission will be downloaded

  • Keeps track of downloaded submissions so everytime you run it only new submissions will get downloaded

  • Downloaded files path for SPOJ submissions will be /spoj/user/problem_name (ex: /spoj/mohd_a/ACODE.cpp)

  • Downloaded files path for Codeforces will be /codeforces/handle/ and then depends on what you choose:

    • If you choose to separate gym and regular contests, there will be /codeforces/handle/gym and /codeforces/handle/regular
    • If you choose to separate each contest in a different folder, a folder with contest's ID will be created for the submissions

    Example paths:

    • Separated gym/regular and separated folders for contests: /codeforces/handle/regular(or gym)/1266/A.cpp
    • Separated gym/regular but no separated folders for each contest: /codeforces/handle/regular(or gym)/1266A.cpp
    • Not separated gym/regular but separated folders for each contest: /codeforces/handle/1266/A.cpp
    • Not seperated gym/regular and no separated folders for each contest: /codeforces/handle/1266A.cpp

Getting Started

Below is a list of requirements and dependencies

Requirements

  • Python3 to run the tool
  • Clone the repository:
git clone https://github.com/Mohd-3/CodeRetriever.git

Dependencies

  • pip - to install the required packages
  • requests - used to get submissions pages
  • bs4 - BeautifulSoup to scrape pages and extract the source code of submissions

Install pip if you don't already have it installed

To download all dependencies use the following command:

pip3 install -r requirements.txt

or if you want to install one by one:

pip3 install bs4
pip3 install requests

Usage

Navigate to the cloned repository's directory and run main.py

cd CodeRetriever
python3 main.py

Alternatively, If you want to use this in your existing project, copy retriever.py to your project's directory and use it as the following:

from retriever import Retriever

starter = Retriever()
starter.start()

# you can also skip the input part and specifiy the arguments directly
starter = Retriever(cf_handle='handle', cf_password='password', spoj_handle='user', spoj_password='password', codeforces=True, spoj=True, get_regular=True, get_gym=True, split_gym=True, folders=True, verbose=True)
starter.start()

# spoj is a boolean specifying whether you want to download spoj submissions or not
# codeforces is a boolean specifying whether you want to download codeforces submissions or not
# get_regular is a boolean specifying whether you want to download regular contests submissions for codeforces
# get_gym is a boolean specifying whether you want to download gym contests submissions for codeforces
# split_gym is a boolean specifying whether you want gym submissions to be separated from regular ones, (gym and regular folders will be created)
# folders is a boolean specifying whether you want to separate each contest's submissions in a different folder (contest ID as folder name)

Codeforces password is only needed if get_gym is set to True, you can skip password if you want to get regular contest submissions only. Set verbose to False to run it without an output about status

Author

  • Mohammed Al-Abdulhadi - Mohd-3

coderetriever's People

Contributors

ishandutta2007 avatar mohd-3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

coderetriever's Issues

Breaks while Scaping codeforeces.

Ideally in such scenarios it should fail gradefull skipping that case not terminate the progrm like it did for me
Here is the stacktrace.

Downloading --> Platform: Codeforces, Submission: 106879107, Contest: 1479, Problem: E
Traceback (most recent call last):
  File ".\main.py", line 8, in <module>
    main()
  File ".\main.py", line 5, in main
    retriever.start()
  File "C:\Users\Public\Documents\Projects\CodeRetriever\retriever.py", line 207, in start
    self.get_submissions()
  File "C:\Users\Public\Documents\Projects\CodeRetriever\retriever.py", line 321, in get_submissions
    self.process_submission(submission)
  File "C:\Users\Public\Documents\Projects\CodeRetriever\retriever.py", line 364, in process_submission
    f.write('\n'.join(self.result.splitlines()))
  File "C:\Users\Admin\.pyenv\pyenv-win\versions\3.7.2\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u250c' in position 13023: character maps to <undefined>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.