Skip to content

Commit

Permalink
fix: parse js object (#26)
Browse files Browse the repository at this point in the history
Signed-off-by: Dup4 <lyuzhi.pan@gmail.com>
  • Loading branch information
Dup4 authored May 19, 2024
1 parent 708c3f0 commit 8b0af96
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions xcpcio_board_spider/spider/zoj/v2/zoj.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def get_team_type(team: Team):
return team.extra[ZOJ.CONSTANT_TEAM_TYPE]

def get_js_object(self, js_code: str, key: str):
text = js_code.lstrip("var {} =".format(key)).rstrip(";\n ")
text = "JSON.stringify(" + text + ")"
text = js_code.lstrip("var {} =".format(key)).replace(
"};", "}").replace("];", "]")
text = "JSON.stringify({})".format(text)
text = execjs.eval(text)

return json.loads(text)

def fetch(self):
Expand Down

0 comments on commit 8b0af96

Please sign in to comment.