more updates
This commit is contained in:
parent
286d21cd0e
commit
c4a7dc8215
10 changed files with 311 additions and 73 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
import requests
|
||||
|
|
@ -57,12 +58,17 @@ def scrape(url: str) -> list[tuple[str, str]]:
|
|||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: atcoder.py <contest_id> <problem_letter>", file=sys.stderr)
|
||||
print("Example: atcoder.py abc042 a", file=sys.stderr)
|
||||
result = {
|
||||
"success": False,
|
||||
"error": "Usage: atcoder.py <contest_id> <problem_letter>",
|
||||
"problem_id": None,
|
||||
}
|
||||
print(json.dumps(result))
|
||||
sys.exit(1)
|
||||
|
||||
contest_id = sys.argv[1]
|
||||
problem_letter = sys.argv[2]
|
||||
problem_id = contest_id + problem_letter
|
||||
|
||||
url = parse_problem_url(contest_id, problem_letter)
|
||||
print(f"Scraping: {url}", file=sys.stderr)
|
||||
|
|
@ -70,17 +76,27 @@ def main():
|
|||
tests = scrape(url)
|
||||
|
||||
if not tests:
|
||||
print(f"No tests found for {contest_id} {problem_letter}", file=sys.stderr)
|
||||
result = {
|
||||
"success": False,
|
||||
"error": f"No tests found for {contest_id} {problem_letter}",
|
||||
"problem_id": problem_id,
|
||||
"url": url,
|
||||
}
|
||||
print(json.dumps(result))
|
||||
sys.exit(1)
|
||||
|
||||
print("---INPUT---")
|
||||
print(len(tests))
|
||||
test_cases = []
|
||||
for input_data, output_data in tests:
|
||||
print(input_data)
|
||||
print("---OUTPUT---")
|
||||
for input_data, output_data in tests:
|
||||
print(output_data)
|
||||
print("---END---")
|
||||
test_cases.append({"input": input_data, "output": output_data})
|
||||
|
||||
result = {
|
||||
"success": True,
|
||||
"problem_id": problem_id,
|
||||
"url": url,
|
||||
"test_cases": test_cases,
|
||||
}
|
||||
|
||||
print(json.dumps(result))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue