coddingtonbear / python-myfitnesspal

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

get_measurements() broken #63

Closed mtthwsar closed 6 years ago

mtthwsar commented 6 years ago

client.get_measurements('Weight') has recently started returning empty.

coddingtonbear commented 6 years ago

Ahh! Unfortunately, this library relies upon scraping the MFP website to return to you the necessary data, so things very often break when UI changes are made to the website. Would you mind filing a pull request fixing the scraper?

mtthwsar commented 6 years ago

Hey Adam,

Thanks for the quick reply, I’ll take a look at it late this week and see if I can figure out what the issue was.

Adam

On May 1, 2018, at 10:51, Adam Coddington notifications@github.com wrote:

Ahh! Unfortunately, this library relies upon scraping the MFP website to return to you the necessary data, so things very often break when UI changes are made to the website. Would you mind filing a pull request fixing the scraper?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/coddingtonbear/python-myfitnesspal/issues/63#issuecomment-385738873, or mute the thread https://github.com/notifications/unsubscribe-auth/AU9BTRnBi-w1NWf8Me9tl3775tq8bdEsks5tuKCYgaJpZM4TuQZw.

zagi commented 6 years ago

Hi Guys, I think this one relates to something other because the UI didn't change. I've made an investigation and seems that it loses the session after first _get_document_for_url() method is called(the one which is responsible for getting the select options). When next _get_document_for_url() call is made the HTML returned don't contain the check-in table, but login wrapper. When I reset the session and login again like that:

self.session = requests.Session()
self._login()

at the beginning of while loop, it returns data as it should.

Maybe it's related to this: image

Anyway, I'll prepare fix and PR it to master.

Mike

zagi commented 6 years ago

No fix is required. I've done all of my tests using requests-2.11.1, after upgrading it to requests-2.18.4 everything works as expected. Any version of requests package lower than 2.17.0 doesn't work.

zagi commented 6 years ago

@coddingtonbear I think we can close this one.

Mike

coddingtonbear commented 6 years ago

thanks @zagi!