What's new

Any Python programmers?

Luc

"To Wiki or Not To Wiki, That's The Question".
Staff member
I guess that Monthy Python is very popular here but, programming in Python isn't.

Quick overview of what I want to do.

I want to program a script that will open the web browser and do a few clicks, read what's on the page, depending on the result, either do more clicks or click next.

So, I use MyFitnessPal. A pain each week to copy last week's breakfasts one by one. Monday to Sunday, I don't have the same meals but each Monday is the same meal.

So I would want to make a script that will load the food diary, and check if there's food logged in the breakfast first (0 calories in the breakfast section should do). Then do a copy from the date and pick last Monday if I'm on Monday. The same goes with the snacks then move to the next day and do it again. I would do a loop like that for 2-3 weeks so it's easier. Increasing or decreasing the loop after should be fairly easy.

I was able to make Selenium work with Python. I'm able to open the web browser on the food diary page. I started looking at tutorials and most seem to use xPath to find their elements in the webpage. I'm having issues finding them.

I got a kid's book at the public library as an introduction to Python. So, I'm doing that right now and I'm printing a lot of Hello World!

There might be an easier way to program it by using a URL that I would feed the web browser using the dates as parameters but I'm not able to make it work. Some variables must be initialized in MyFitnessPal and my Java knowledge is null.

So, any trick on finding those xPath ? Is it a plugin that I need to install so that I can right-click -> xPath?
 
I will have a look but their main page mentioned that they are not taking new requests.

I took that to mean partner requests; the API is open so you could just test a call and see if user access is still enabled.
However, I did not see any mention of the food dairy in the doc.

Sorry, I didn't look too closely, just saw that they had one and thought that would be so much easier than scripting browser interactions. :p
 
  • Like
Reactions: Luc

Luc

"To Wiki or Not To Wiki, That's The Question".
Staff member
Ok, found the elements and was able to do a click via the JavaScript console.

The issue is when a click is performed, the page reloads. Any future commands are lost since it’s a new page.

Back to selenium. I found where to click to get that xPath in the inspect function.

I should be able to work something with Python.
 

Doc4

Stumpy in cold weather
Staff member
I should be able to work something with Python.
1726369216210.png
 
  • Haha
Reactions: Luc
Top Bottom