Python 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
... from bs4 import BeautifulSoup
... from lxml import html
... import re
... def extract_numbers(text):
...     pattern = r'(\d+)\s*/\s*(\d+)'
...     match = re.search(pattern, text)
...     if match:
...         return int(match.group(1)), int(match.group(2))
...     else:
...         return None, None
... login_url = 'http://8.136.99.126/login'
... username = '035966_L3'
... password = '***********'
... session = requests.Session()
... payload = {'uname': username, 'password': password, 'rememberme': True}
... response = session.post(login_url, data = payload)
... if response.ok == False:
...     print('Login failed!')
...     print('Press any key to continue...')
...     input()
...     sys.exit(1)
... url = 'http://8.136.99.126/p?page='
... page = 0
... count = 0
... submits = 0
... continous = True
... while continous:
...     continous = False
...     page = page + 1
...     content = session.get(url + str(page))
...     if content.status_code == 200:
...         soup = BeautifulSoup(content.text, 'html.parser')
...         text = soup.get_text()
...         lines = text.splitlines()
...         for line in lines:
...             num1, num2 = extract_numbers(line)
...             if num1 != None:
...                 continous = True
...                 count = count + 1
...                 submits = submits + num2
...     else:
...         print('Crawling Failed!')
...         print('Press any key to continue...')
...         input()
...         sys.exit(1)
... print('Crawled!')
... print('Problem Count:', count)
... print('Submission Count:', submits)
... print('Press any key to continue...')
... input()

Crawled!
Problem Count: 208
Submission Count: 3000
Press any key to continue...

2 댓글

  • @ 2025-9-14 10:58:24

    这个代码是什么?

    • @ 2025-9-14 11:09:48

      评测和题目数量检测

  • @ 2025-9-14 9:01:28

    qp

    • 1