Skip to content

Get gym solution for parser #363

@unaimillan

Description

@unaimillan

Would be cool to add a parser function similar to get_solution, but for mashup contests created in gym.
Implementation should be similar, except for /gym/ in the url path

def get_gym_solution(self, contest_id, submit_id):
    solutionPage = self.session.get(
        "https://codeforces.com/gym/"
        + str(contest_id)
        + "/submission/"
        + str(submit_id)
    )
    if int(solutionPage.status_code) != 200:
        raise Exception("Returned not OK code " + str(solutionPage))
    tree2 = html.fromstring(solutionPage.text)
    code = tree2.xpath("//pre[@id='program-source-text']/text()")
    if len(code) == 0:
        raise ValueError("Incorrect contest_id or submit_id " + str(code))
    return code[0].replace("\r", "")

or just add one more parameter to get_solution with default value gym=False

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions