Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import requests
- from bs4 import BeautifulSoup
- from random import choice
- import json
- from datetime import datetime
- handles = ['Omelet', '03t', 'Kevin_Zhang', '我在膜拜祢', 'eric_xiao', 'cwcodinglife']
- probs = [1166, 1040, 1137, 1445, 1787]
- def getranklist(pid):
- res = requests.get(f'https://tioj.ck.tp.edu.tw/problems/{str(pid)}/ranklist')
- soup = BeautifulSoup(res.text, features="lxml")
- rk = soup.find_all('tr')[1:]
- return sorted(list([
- (lambda s: { 'sid': s[1], 'handle': s[3], 'time': datetime.strptime(s[8], "%Y-%m-%d %H:%M:%S")})(
- [tag.text for tag in row.find_all('td')]
- )
- for row in rk]), key = lambda s: s['time'])
- score = {}
- firstac = {}
- for handle in handles:
- score[handle] = 0
- for prob in probs:
- for user in getranklist(prob):
- handle = user['handle']
- if handle in handles:
- score[handle] += 1
- firstac[prob] = handle
- break
- print(score)
- print(firstac)
Advertisement
Add Comment
Please, Sign In to add comment