nh.51goc.com 评测结果爬虫
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.options import Options
import time, re
options = Options()
options.add_argument("--headless=new")
options.add_argument("--disable-gpu")
options.add_argument('--log-level=3')
driver = webdriver.Edge(options = options)
url = "https://nh.51goc.com/problem/submissions/code/"
name = "黄海韬"
username = "sm黄海韬"
password = "sm2025"
while True:
try:
rid = int(input('start from: '))
except ValueError: continue
driver.get("https://nh.51goc.com/login")
time.sleep(1)
inputs = driver.find_elements(By.TAG_NAME, 'input')
if inputs:
inputs[0].send_keys(username)
inputs[1].send_keys(password)
driver.find_element(By.TAG_NAME, 'button').click()
time.sleep(1)
while True:
rid = rid + 1
driver.get(url = url + str(rid))
if driver.title == "错误提示!": continue
HTML = driver.page_source
if not re.findall(f"提交人:{name}", HTML): break
print(url + str(rid))
print(driver.find_element(By.XPATH, "/html/body/div/div/div/span[1]").text)
print(driver.find_element(By.XPATH, "/html/body/div/div/div/span[2]/label[2]").text[5:])
print()
print('end at:', rid - 1)
driver.close()upd on 2025/9/4