LeetCode-Anki icon indicating copy to clipboard operation
LeetCode-Anki copied to clipboard

Failed to fetch solution?

Open pinelop opened this issue 4 years ago • 5 comments

I get for almost all problems:

Failed to execute <bound method LeetCodeCrawler.fetch_solution of <crawler.LeetCodeCrawler object at 0x105034550>>, Reason: 'NoneType' object is not subscriptable

Any ideas?

pinelop avatar Feb 20 '21 22:02 pinelop

Could you describe how the error occurs in detail? It is very difficult for me to figure out why from the error log

Peng-YM avatar Feb 21 '21 02:02 Peng-YM

The issue seems to be the following, otherwise its a 404 for /problem/

     def fetch_problem(self, slug, accepted=False):
-        print(f"🤖 Fetching problem: https://leetcode.com/problem/{slug}/...")
+        print(f"🤖 Fetching problem: https://leetcode.com/problems/{slug}/...")

pinelop avatar Feb 21 '21 10:02 pinelop

The issue seems to be the following, otherwise its a 404 for /problem/

     def fetch_problem(self, slug, accepted=False):
-        print(f"🤖 Fetching problem: https://leetcode.com/problem/{slug}/...")
+        print(f"🤖 Fetching problem: https://leetcode.com/problems/{slug}/...")

For me it works now with this change, I also changed question_id to frontend_question_id so I can pass my self problems to be included as what the user seems to be actually frontend_question_id.

Is it working for you at API /problem/ ?

pinelop avatar Feb 21 '21 17:02 pinelop

For the original question,

Failed to execute <bound method LeetCodeCrawler.fetch_solution of <crawler.LeetCodeCrawler object at 0x105034550>>, Reason: 'NoneType' object is not subscriptable

This happens when there isn't a solution for the problem on LeetCode. Not all problems have an available solution. It would be good to catch the error and print it or at least indicate this in the readme.

jchan172 avatar May 29 '21 01:05 jchan172

These days I am pretty busy, could you consider opening a PR to fix this issue? Thank you very much for your information.

Peng-YM avatar May 29 '21 02:05 Peng-YM