Documentation ¶
Index ¶
- Constants
- Variables
- func Start(headless bool, userDataDir, bin string) error
- func StartWithCacheDir(headless bool, userDataDir, bin, cacheDir string) error
- type Args
- func (arg Args) ContestsPage() (link string, err error)
- func (arg Args) CountdownPage() (link string, err error)
- func (arg Args) DashboardPage() (link string, err error)
- func (arg Args) GetContests(pageCount uint) (<-chan []Contest, error)
- func (arg Args) GetCountdown() (time.Duration, error)
- func (arg Args) GetDashboard() (Dashboard, error)
- func (arg Args) GetProblems() ([]Problem, error)
- func (arg Args) GetSubmissions(handle string, pageCount uint) (<-chan []Submission, error)
- func (arg Args) ProblemsPage() (link string, err error)
- func (arg Args) RegisterPage() (link string, err error)
- func (arg Args) String() (str string)
- func (arg Args) SubmissionsPage(handle string) (link string, err error)
- func (arg Args) SubmitSolution(langName string, file string) (<-chan Submission, error)
- type Contest
- type Dashboard
- type Problem
- type SampleTest
- type Submission
Constants ¶
const ( ClassContest = "contest" ClassGroup = "group" ClassGym = "gym" )
Class type of contest.
const ( RegistrationClosed = 0 RegistrationOpen = 1 RegistrationDone = 2 RegistrationNotExists = -1 )
Contest registration status.
const ( SolveAccepted = 1 SolveRejected = 0 SolveNotAttempted = -1 )
Different values of 'SolveStatus'.
const ( VerdictAC = 1 // Accepted VerdictWA = 2 // Wrong Answer VerdictRTE = 4 // Run Time Error VerdictCE = 5 // Compilation Error VerdictTLE = 6 // Time Limit Exceeded VerdictMLE = 7 // Memory Limit Exceeded VerdictILE = 8 // Idleness Limit Exceeded VerdictDOJ = 9 // Denial Of Judgement VerdictSkip = 10 // Skipped VerdictHack = 11 // Hacked // Depreciated. Use VerdictAC instead. VerdictPretestPass = 12 // Pretests passed )
Submissions verdict status.
Variables ¶
var ( // LanguageID represents all available languages with ids. LanguageID = map[string]string{ "Microsoft Visual C++ 2010": "2", "Delphi 7": "3", "Free Pascal 3.0.2": "4", "PHP 7.2.13": "6", "Python 2.7.18": "7", "C# Mono 6.8": "9", "Haskell GHC 8.10.1": "12", "Perl 5.20.1": "13", "ActiveTcl 8.5": "14", "Io-2008-01-07 (Win32)": "15", "Pike 7.8": "17", "Befunge": "18", "OCaml 4.02.1": "19", "Scala 2.12.8": "20", "OpenCobol 1.0": "22", "Factor": "25", "Secret_171": "26", "Roco": "27", "D DMD32 v2.091.0": "28", "Python 3.9.1": "31", "Go 1.15.6": "32", "Ada GNAT 4": "33", "JavaScript V8 4.8.0": "34", "Java 1.8.0_241": "36", "Mysterious Language": "38", "FALSE": "39", "PyPy 2.7 (7.3.0)": "40", "PyPy 3.7 (7.3.0)": "41", "GNU G++11 5.1.0": "42", "GNU GCC C11 5.1.0": "43", "Picat 0.9": "44", "GNU C++11 5 ZIP": "45", "Java 8 ZIP": "46", "J": "47", "Kotlin 1.4.0": "48", "Rust 1.49.0": "49", "GNU G++14 6.4.0": "50", "PascalABC.NET 3.4.2": "51", "Clang++17 Diagnostics": "52", "GNU G++17 7.3.0": "54", "Node.js 12.6.3": "55", "Microsoft Q#": "56", "Text": "57", "Microsoft Visual C++ 2017": "59", "Java 11.0.6": "60", "GNU G++17 9.2.0 (64 bit, msys 2)": "61", "UnknownX": "62", "C# 8, .NET Core 3.1": "65", "Ruby 3.0.0": "67", "Secret 2021": "68", } // LanguageExtn corresponds to file extension of // given language source code. LanguageExtn = map[string]string{ "GNU C11": ".c", "Clang++17 Diagnostics": ".cpp", "GNU C++0x": ".cpp", "GNU C++": ".cpp", "GNU C++11": ".cpp", "GNU C++14": ".cpp", "GNU C++17": ".cpp", "MS C++": ".cpp", "MS C++ 2017": ".cpp", "GNU C++17 (64)": ".cpp", "Mono C#": ".cs", "D": ".d", "Go": ".go", "Haskell": ".hs", "Kotlin": ".kt", "Ocaml": ".ml", "Delphi": ".pas", "FPC": ".pas", "PascalABC.NET": ".pas", "Perl": ".pl", "PHP": ".php", "Python 2": ".py", "Python 3": ".py", "PyPy 2": ".py", "PyPy 3": ".py", "Ruby": ".rb", "Rust": ".rs", "JavaScript": ".js", "Node.js": ".js", "Q#": ".qs", "Java": ".java", "Java 6": ".java", "Java 7": ".java", "Java 8": ".java", "Java 9": ".java", "Java 10": ".java", "Java 11": ".java", "Tcl": ".tcl", "F#": ".fs", "Befunge": ".bf", "Pike": ".pike", "Io": ".io", "Factor": ".factor", "Cobol": ".cbl", "Secret_171": ".secret_171", "Ada": ".adb", "FALSE": ".f", "": ".txt", } )
var ( // Browser is the headless browser to use. Browser *rod.Browser )
var (
ErrInvalidSpecifier = fmt.Errorf("invalid specifier data")
)
Errors returned by library.
Functions ¶
func StartWithCacheDir ¶ added in v2.2.0
StartWithCacheDir is the same as Start, only allows to set cacheDir to use.
Types ¶
type Args ¶
Args holds specifier details parsed by Parse() function. All methods use this at the core.
func Parse ¶
Parse passed in specifier string to new Args struct. Validates parsed args and returns error if any.
func (Args) ContestsPage ¶
ContestsPage returns link to contests page of group/gym/contest.
func (Args) CountdownPage ¶
CountdownPage returns link to countdown in contest.
func (Args) DashboardPage ¶
DashboardPage returns link to dashboard of contest.
func (Args) GetContests ¶
GetContests returns metadata of the given contest(s).
Set 'pageCount' to the maximum number of pages to parse. Each page consists of 100 rows of data, except the first page, which may contain additional upcoming contests data.
func (Args) GetCountdown ¶
GetCountdown returns the time before the given contest begins. If contest has already started, returns 0.
Use this function instead of GetContests to get countdown, as it supports returning countdown of virtual contests too.
func (Args) GetDashboard ¶
GetDashboard returns in depth contest metadata from the contest dashboard page.
Data returned by this function is user session specific, as user interaction in the contest is parsed and returned.
func (Args) GetProblems ¶
GetProblems returns problem(s) meta data, along with sample tests.
If the problem is not specified, returns data of all problems in the specified contest. In some older contests, the complete problemset page is not present. In such cases, fallback to running GetProblems() for each problem in the contest.
SolveStatus and SolveCount are not parsed by this. Use GetDashboard() if you require these fields.
func (Args) GetSubmissions ¶
func (arg Args) GetSubmissions(handle string, pageCount uint) (<-chan []Submission, error)
GetSubmissions returns submissions metadata of given user. If contest is not specified, returns all submissions of user.
Due to a bug on codeforces, fetching submissions in group contests are not supported, when the contest isn't specified.
Set pageCount to maximum number of pages to parse. Each page consists of 50 rows of data. If pageCount is 1, the returned channel will keep returning page data, till all verdicts of submissions in the page are declared.
func (Args) ProblemsPage ¶
ProblemsPage returns link to problem(s) page in contest.
func (Args) RegisterPage ¶
RegisterPage returns link to registration (not virtual contest registration) in contest.
func (Args) SubmissionsPage ¶
SubmissionsPage returns link to user submissions page.
func (Args) SubmitSolution ¶
func (arg Args) SubmitSolution(langName string, file string) (<-chan Submission, error)
SubmitSolution submits given file to the judging server, and returns a channel on a successful submission. The channel contains the live status of the submission. View GetSubmissions() for more details on the returned channel.
langName is the codeforces configured language to use. See the variable map LanguageID for the list of supported languages.
type Contest ¶
type Contest struct { Name string Writers []string StartTime time.Time Duration time.Duration RegCount int RegStatus int Description []string Arg Args }
Contest holds details from contest row from contests table.
type Dashboard ¶
type Dashboard struct { Name string Problem []Problem Countdown time.Duration // href link => description Material map[string]string }
Dashboard holds details from contest dashboard.
type Problem ¶
type Problem struct { Name string TimeLimit string MemoryLimit string InpStream string OutStream string SampleTests []SampleTest SolveCount int SolveStatus int Arg Args }
Problem holds data of problem.
type SampleTest ¶
SampleTest holds sample test case data.
type Submission ¶
type Submission struct { ID string When time.Time Who string Problem string Language string Verdict string VerdictStatus int Time string Memory string IsJudging bool Arg Args }
Submission holds submission data.
func (Submission) GetSourceCode ¶
func (sub Submission) GetSourceCode() (string, error)
GetSourceCode returns submission code of given submission.
func (Submission) SourceCodePage ¶
func (sub Submission) SourceCodePage() (link string, err error)
SourceCodePage returns link to solution submission code.