Блог пользователя jefferyfan3a

Автор jefferyfan3a, история, 5 лет назад, По-английски

Hi! I tried to download all of the CodeForces problems down for a ib cs hl project. I used wget and I have gotten 403 forbiddened after that.And I have to use vpns to enter CodeForces now. Is there any way to fix this? Please leave reasons of why you downvoted. Don't just leave downvotes and leave.... Thank you!

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I think you should post wget query you tried to execute. But besides I don't think there is REST query to download all tasks from cf and there should be one.

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I did it using python request library.

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    How did you not get banned?

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      How did you? :P You can use this script

      import requests
      
      with requests.Session() as s:
          problems = s.get("https://codeforces.com/api/problemset.problems").json()
      
          for problem in problems['result']['problems']:
              cid = problem['contestId']
              name = problem['index']
      
              response = s.get(f'https://codeforces.com/problemset/problem/{cid}/{name}')
              assert response.status_code == 200
      
              # Do whatever you want with `problem_page`
              problem_page = response.text
              print(f"Downloaded: Problem {name} Contest {cid}")