coddingtonbear / python-myfitnesspal

Access your meal tracking data stored in MyFitnessPal programatically
MIT License
794 stars 138 forks source link

HtmlElement has no attribute classes #68

Closed Cokemonkey11 closed 5 years ago

Cokemonkey11 commented 6 years ago

Seems to be a small hole in error handling?

>>> import myfitnesspal
>>> client = myfitnesspal.Client('Cokemonkey11')
>>> day = client.get_date(2017, 9, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/myfitnesspal/client.py", line 482, in get_date
    complete = self._get_completion(document)
  File "/usr/local/lib/python3.4/dist-packages/myfitnesspal/client.py", line 259, in _get_completion
    if "day_incomplete_message" in completion_message.classes:
AttributeError: 'HtmlElement' object has no attribute 'classes'

Thanks for your work on this!

coddingtonbear commented 5 years ago

My current guess is that this is related to changes between lxml 3 and lxml 4 given that I do see that attribute existing, and I'm using lxml 4.2.5 in my environment. Could you try upgrading to lxml 4.2.5 to see if that resolves this? If so, I can just update the requirements.txt file to require a newer version.

coddingtonbear commented 5 years ago

Updating lxml to 4.2.5 is harmless enough that I've now increased our minimum version requirement to hopefully avert the problem you encountered earlier. Thanks for your bug report!