Peng-YM/LeetCode-Anki

Failed to fetch solution?

pinelop opened this issue ยท 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?

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

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}/...")

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/ ?

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.

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