跳到正文

个人记录

GMOJ自动寻找小地球

aaron0919约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前
Python
import requests, re, webbrowser

cookies = {
    # 你的cookies
}

headers = {
    # 你的headers
}

problem_id = 3899 # 要搜索的ID

r = re.compile(
    '100.{0,150}<a href="(#main/code/\\d+)">C\\+\\+.{0,80}<i\\ class="icon\\-globe"></i>'
)

for i in range(1, 21):
    response = requests.get(
        f"https://gmoj.net/senior/index.php/main/statistic/{problem_id}/{i}",
        cookies=cookies,
        headers=headers,
    )
    html = response.content.decode()
    with open(".\other\oj.html", "w") as f:
        f.write(html)
    s = r.findall(html)
    if s:
        for i in s:
            print("https://gmoj.net/senior/%s" % i)
            webbrowser.open("https://gmoj.net/senior/%s" % i)
原文