mirror of
https://github.com/QingdaoU/OpenVJ.git
synced 2024-12-29 07:51:45 +00:00
修复正则中不正确的转义
This commit is contained in:
parent
43c5cb2825
commit
01483a1b6a
@ -16,7 +16,7 @@ class CodeForcesRobot(Robot):
|
||||
def _get_token(self):
|
||||
r = self.get("http://codeforces.com/enter", headers={"Referer": "http://codeforces.com/enter"})
|
||||
self.check_status_code(r)
|
||||
self.token = re.compile(r"<meta name=\"X-Csrf-Token\" content=\"([\s\S]*?)\"/>").findall(r.text)[0]
|
||||
self.token = re.compile(r'<meta name="X-Csrf-Token" content="([\s\S]*?)"/>').findall(r.text)[0]
|
||||
self.cookies = dict(r.cookies)
|
||||
|
||||
def login(self, username, password):
|
||||
@ -36,14 +36,14 @@ class CodeForcesRobot(Robot):
|
||||
|
||||
def get_problem(self, url):
|
||||
r = self.get(url, headers={"Referer": "https://codeforces.com"})
|
||||
regex = {"title": r"<div class=\"header\"><div class=\"title\">([\s\S]*?)</div>",
|
||||
"time_limit": r"<div class=\"time-limit\"><div class=\"property-title\">time limit per test</div>(\d+)\s*seconds</div>",
|
||||
"memory_limit": r"<div class=\"memory-limit\"><div class=\"property-title\">memory limit per test</div>(\d+)\s*megabytes</div>",
|
||||
"description": r"<div class=\"output-file\"><div class=\"property-title\">output</div>[\s\S]*?</div></div><div>([\s\S]*?)</div>",
|
||||
"input_description": r"<div class=\"section-title\">Input</div>([\s\S]*?)</div>",
|
||||
"output_description": r"<div class=\"section-title\">Output</div>([\s\s]*?)</div>"}
|
||||
input_samples_regex = r"<div class=\"title\">Input</div><pre>([\s\S]*?)</pre></div>"
|
||||
output_samples_regex = r"<div class=\"title\">Output</div><pre>([\s\S]*?)</pre></div>"
|
||||
regex = {"title": r'<div class="header"><div class="title">([\s\S]*?)</div>',
|
||||
"time_limit": r'<div class="time-limit"><div class="property-title">time limit per test</div>(\d+)\s*seconds</div>',
|
||||
"memory_limit": r'<div class="memory-limit"><div class="property-title">memory limit per test</div>(\d+)\s*megabytes</div>',
|
||||
"description": r'<div class="output-file"><div class="property-title">output</div>[\s\S]*?</div></div><div>([\s\S]*?)</div>',
|
||||
"input_description": r'<div class="section-title">Input</div>([\s\S]*?)</div>',
|
||||
"output_description": r'<div class="section-title">Output</div>([\s\s]*?)</div>'}
|
||||
input_samples_regex = r'<div class="title">Input</div><pre>([\s\S]*?)</pre></div>'
|
||||
output_samples_regex = r'<div class="title">Output</div><pre>([\s\S]*?)</pre></div>'
|
||||
data = {}
|
||||
for k, v in regex.items():
|
||||
items = re.compile(v).findall(r.text)
|
||||
|
@ -15,8 +15,9 @@ class PATRobot(Robot):
|
||||
return re.compile(regex).match(url) is not None
|
||||
|
||||
def _get_token(self):
|
||||
r = self.get("http://www.patest.cn/contests", cookies=self.cookies)
|
||||
self.token = re.compile(r"<meta content=\"(.*)\" name=\"csrf-token\" />").findall(r.text)[0]
|
||||
r = self.get("https://www.patest.cn/contests", cookies=self.cookies)
|
||||
self.check_status_code(r)
|
||||
self.token = re.compile(r'<meta content="(.*)" name="csrf-token" />').findall(r.text)[0]
|
||||
|
||||
def login(self, username, password):
|
||||
r = self.post("http://www.patest.cn/users/sign_in",
|
||||
@ -43,14 +44,16 @@ class PATRobot(Robot):
|
||||
def get_problem(self, url):
|
||||
if not self.check_url(url):
|
||||
raise RequestFailed("Invalid PAT url")
|
||||
problem_id = "pat-" + "-".join(re.compile(r"^http://www.patest.cn/contests/pat-(a|b|t)-practise/(\d{4})$").findall(url)[0])
|
||||
regex = {"title": r"<div id=\"body\" class=\"span-22 last\">\s*<h1>(.*)</h1>",
|
||||
problem_id = "pat-" + "-".join(re.compile(r"^https://www.patest.cn/contests/pat-(a|b|t)-practise/(\d{4})$").findall(url)[0])
|
||||
regex = {"title": r'<div id="body" class="span-22 last">\s*<h1>(.*)</h1>',
|
||||
"time_limit": r"<div class='key'>\s*时间限制\s*</div>\s*<div class='value'>\s*(\d+) ms",
|
||||
"memory_limit": r"<div class='key'>\s*内存限制\s*</div>\s*<div class='value'>\s*(\d+) kB",
|
||||
"description": r"<div id='problemContent'>([\s\S]*?)<b>\s*(?:Input|Input Specification:|输入格式:)\s*</b",
|
||||
"input_description": r"<b>\s*(?:Input|Input Specification:|输入格式:)\s*</b>([\s\S]*?)<b>\s*(?:Output|Output Specification:|输出格式:)\s*</b>",
|
||||
"output_description": r"<b>\s*(?:Output|Output Specification:|输出格式:)\s*</b>([\s\S]*?)<b>\s*(?:Sample Input|输入样例).*</b>",
|
||||
"samples": r"<b>\s*(?:Sample Input|输入样例)\s*(?P<t_id>\d?).?</b>\s*<pre>([\s\S]*?)</pre>\s+<b>(?:Sample Output|输出样例)\s?(?P=t_id).?</b>\s*<pre>([\s\S]*?)</pre>"}
|
||||
"samples": r"<b>\s*(?:Sample Input|输入样例)\s*(?P<t_id>\d?).?</b>\s*<pre>([\s\S]*?)</pre>\s+<b>(?:Sample Output|输出样例)\s?(?P=t_id).?</b>\s*<pre>([\s\S]*?)</pre>",
|
||||
"submit_url": r'<form accept-charset="UTF-8" action="([\s\S]*?)" method="post">'}
|
||||
|
||||
data = self._regex_page(url, regex)
|
||||
data["id"] = problem_id
|
||||
return data
|
||||
|
@ -6,9 +6,9 @@ class Language(object):
|
||||
|
||||
|
||||
class Result(object):
|
||||
accepted = 0,
|
||||
accepted = 0
|
||||
runtime_error = 1
|
||||
time_limit_exceeded = 2,
|
||||
time_limit_exceeded = 2
|
||||
memory_limit_exceeded = 3
|
||||
compile_error = 4
|
||||
format_error = 5
|
||||
|
Loading…
Reference in New Issue
Block a user