(self, id, slug, paid_only)
| 113 | return j['data']['question']['translatedTitle'] |
| 114 | |
| 115 | def get_title_with_slug(self, id, slug, paid_only): |
| 116 | content = self.get_problem_content(id) |
| 117 | |
| 118 | if content: |
| 119 | j = json.loads(content) |
| 120 | return j['data']['question']['translatedTitle'] |
| 121 | |
| 122 | session = requests.Session() |
| 123 | headers = {'User-Agent': user_agent, 'Connection': |
| 124 | 'keep-alive', 'Content-Type': 'application/json', |
| 125 | 'Referer': withUrl('problems/') + slug} |
| 126 | |
| 127 | url = withUrl('graphql') |
| 128 | params = {'operationName': "getQuestionDetail", |
| 129 | 'variables': {'titleSlug': slug}, |
| 130 | 'query': '''query getQuestionDetail($titleSlug: String!) { |
| 131 | question(titleSlug: $titleSlug) { |
| 132 | questionId |
| 133 | questionFrontendId |
| 134 | questionTitle |
| 135 | questionTitleSlug |
| 136 | translatedTitle |
| 137 | translatedContent |
| 138 | content |
| 139 | difficulty |
| 140 | stats |
| 141 | similarQuestions |
| 142 | categoryTitle |
| 143 | topicTags { |
| 144 | name |
| 145 | slug |
| 146 | } |
| 147 | } |
| 148 | }'''} |
| 149 | |
| 150 | json_data = json.dumps(params).encode('utf8') |
| 151 | resp = session.post(url, data=json_data, headers=headers, timeout=10) |
| 152 | content = resp.text |
| 153 | j = json.loads(content) |
| 154 | j['data']['question']['paid_only'] = paid_only |
| 155 | self.save_problem(id, json.dumps(j)) |
| 156 | return j['data']['question']['translatedTitle'] |
| 157 | |
| 158 | def get_update_db_time(self): |
| 159 | t = self.dict.get("leetcode_update_db_time") |
no test coverage detected