def get_problem_info(self, problem_id): try: url = 'http://loj.ac/problems/search?keyword={}'.format(problem_id) res = SpiderHttp().get(url=url) data = re.findall(r'<td>(\d+)</td>\n.*<td>(\d+)</td>', res.text)[0] accept = int(data[0]) total = int(data[1]) rating = int(calculate_problem_rating(total, accept)) except: rating = DEFAULT_PROBLEM_RATING return {'rating': rating}
def get_problem_info(self, problem_id): try: url = 'https://nanti.jisuanke.com/t/{}'.format(problem_id) res = SpiderHttp().get(url=url) data = re.findall(r'通过 (\d+) 人次 / 提交 (\d+) 人次', res.text) accept = int(data[0][0]) total = int(data[0][1]) rating = int(calculate_problem_rating(total, accept)) except: rating = DEFAULT_PROBLEM_RATING return {'rating': rating}
def get_problem_info(self, problem_id): url = 'http://acm.hdu.edu.cn/showproblem.php?pid={}'.format(problem_id) res = SpiderHttp().get(url=url) try: re_res = re.search( r'<br>Total Submission\(s\): (\d+)( ){4}Accepted Submission\(s\): (\d+)<br>', res.text) total = int(re_res.group(1)) accept = int(re_res.group(3)) rating = calculate_problem_rating(total, accept) except: rating = DEFAULT_PROBLEM_RATING return {'rating': rating}
def get_problem_info(self, problem_id): url = 'http://poj.org/problem?id={}'.format(problem_id) res = SpiderHttp().get(url=url) try: total = int( re.search(r'<td><b>Total Submissions:</b> (\d+)</td>', res.text).group(1)) accept = int( re.search(r'<td><b>Accepted:</b> (\d+)</td>', res.text).group(1)) rating = calculate_problem_rating(total, accept) except: rating = DEFAULT_PROBLEM_RATING return {'rating': rating}
def get_problem_info(self, problem_id): url = 'http://acm.zucc.edu.cn/problem.php?id={}'.format(problem_id) res = ZuccHttp().get(url=url) try: total = int( re.search(r'Submit: </span>(\d+)( )*<span', res.text).group(1)) accept = int( re.search(r'Solved: </span>(\d+)( )*<br>', res.text).group(1)) rating = int(calculate_problem_rating(total, accept) * 0.8) except: rating = DEFAULT_PROBLEM_RATING return {'rating': rating}
def get_problem_info(self, problem_id): url = 'https://www.nitacm.com/problem_stat.php?pid={}'.format( problem_id) res = SpiderHttp().get(url=url) try: selector = Selector(res.text) total = int( selector.xpath( '//*[@id="probstat"]/tbody/tr[1]/td/a/text()').get()) accept = int( selector.xpath( '//*[@id="probstat"]/tbody/tr[2]/td/a/text()').get()) rating = calculate_problem_rating(total, accept) except: rating = DEFAULT_PROBLEM_RATING return {'rating': rating}
def get_problem_info(self, problem_id): url = 'https://www.luogu.com.cn/problem/P{}'.format(problem_id) res = LuoguHttp().get(url=url) try: res_raw = re.search(r'decodeURIComponent\("(.*)"\)\);', res.text).group(1) res_str = unquote(res_raw) res_json = json.loads(res_str) total = res_json['currentData']['problem']['totalSubmit'] accept = res_json['currentData']['problem']['totalAccepted'] rating = int(calculate_problem_rating(total, accept) * 1.1) except: rating = DEFAULT_PROBLEM_RATING return {'rating': rating}
def get_problem_info(self, problem_id): problem_id = int(problem_id) - 1000 url = 'http://acm.zju.edu.cn/onlinejudge/showProblemStatus.do?problemId={}'.format( problem_id) res = SpiderHttp().get(url=url) try: selector = Selector(res.text) total = int( selector.xpath( '//*[@id="content_body"]/div[2]/table/tr[2]/td[10]/a/text()' ).get()) accept_tmp = selector.xpath( '//*[@id="content_body"]/div[2]/table/tr[2]/td[1]/a/text()' ).get() accept = int(re.search(r'(\d+)\(\d+%+\)', accept_tmp).group(1)) rating = calculate_problem_rating(total, accept) except: rating = DEFAULT_PROBLEM_RATING return {'rating': rating}
def get_problem_info(self, problem_id): url = 'https://www.lydsy.com/JudgeOnline/problem.php?id={}'.format( problem_id) headers = { 'host': 'www.lydsy.com', 'referer': 'https://www.lydsy.com/JudgeOnline/problemset.php' } res = HysbzHttp().get(url=url, headers=headers) try: total = int( re.search( r'<span class=green>Submit: </span>(\d+) ', res.text).group(1)) accept = int( re.search(r'<span class=green>Solved: </span>(\d+)<br>', res.text).group(1)) rating = calculate_problem_rating(total, accept) except: rating = DEFAULT_PROBLEM_RATING return {'rating': rating}