Skip to content

Commit

Permalink
fix(platform): CodeForces JSON error
Browse files Browse the repository at this point in the history
- HTML body was decoded by json incorrectly earlier (fixed in this
  commit)
  • Loading branch information
adityaa30 committed Sep 28, 2020
1 parent 0c7e6cb commit bb35b0a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/cpcli/platforms/codeforces.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
import logging
from typing import List

Expand All @@ -23,17 +22,16 @@ def uri_prefix():
return 'cf'

def get_questions(self) -> List[Question]:
logger.info(f'Downloading page {self.base_url}/{self.contest}')
logger.info(f'Downloading page {self.base_url}/contest/{self.contest}/problems')

response_code, body = self.download_response(f"/contest/{self.contest}/problems")
if response_code != 200:
err = Exception(f'No contest found for codechef/{self.contest} ❌❌')
raise err

data = json.loads(body)
questions: List[Question] = []

doc = document_fromstring(data)
doc = document_fromstring(body)
caption = doc.xpath('//div[@class="caption"]/text()')[0]

logger.info(f'Found: {caption} ✅')
Expand Down

0 comments on commit bb35b0a

Please sign in to comment.