📜  microsoft todo for linux - Shell-Bash (1)

📅  最后修改于: 2023-12-03 14:44:17.387000             🧑  作者: Mango

Microsoft ToDo for Linux - Shell-Bash

Microsoft ToDo is a popular to-do list app that helps you organize your tasks, manage your time, and increase your productivity. The app is available on various platforms including Windows, Android, and iOS but unfortunately not officially available for Linux.

However, as a programmer, you can still use Microsoft ToDo on your Linux machine with the help of Shell-Bash. In this article, we will explore how to use Microsoft ToDo on Linux using Shell-Bash.

Prerequisites

Before we begin, make sure that you have the following prerequisites:

  • Linux machine with Bash shell
  • WSL (Windows Subsystem for Linux) or Windows VM
Installation

To use Microsoft ToDo on Linux, you need to have the Microsoft Edge browser installed on your machine. You can download it from the following link:

Download Microsoft Edge

Once you have installed Microsoft Edge, you can proceed with the following steps:

Step 1: Download Chromedriver

In order to automate the web application, we will need to have the Google Chrome web driver. To download it, run the following command in your terminal:

wget https://chromedriver.storage.googleapis.com/79.0.3945.36/chromedriver_linux64.zip

Extract it using the following command:

unzip chromedriver_linux64.zip
Step 2: Install Selenium and BeautifulSoup

We need to install the Selenium and Beautiful Soup libraries to automate web applications. Run the following commands in your terminal:

pip install selenium
pip install beautifulsoup4
Step 3: Create a Bash Script

Create a Bash script with the following code:

#!/bin/bash
export DISPLAY=:0
cd /path/to/your/folder
/usr/bin/python3 todo.py
Step 4: Create a Python Script

Create a Python script with the following code:

from selenium import webdriver
from bs4 import BeautifulSoup
import time

username = "Your Microsoft ToDo email"
password = "Your Microsoft ToDo password"
todo_url = "https://to-do.live.com/tasks/"

options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")

driver = webdriver.Chrome("/path/to/your/chromedriver", options=options)

driver.get(todo_url)
time.sleep(5)

driver.find_element_by_id("i0116").send_keys(username)
driver.find_element_by_id("idSIButton9").click()
time.sleep(5)

driver.find_element_by_id("i0118").send_keys(password)
driver.find_element_by_id("idSIButton9").click()
time.sleep(5)

driver.get(todo_url)
time.sleep(5)

html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')

tasks = []
for task in soup.find_all("div", class_="taskItem"):
    task_name = task.find("div", class_="taskName ng-binding").text.strip()
    task_date = task.find("div", class_="lastModifiedTime ng-binding").text.strip()
    tasks.append(task_name + ' (' + task_date + ')')

for task in tasks:
    print(task)

Replace the following placeholders with your own credentials:

  • Your Microsoft ToDo email (username)
  • Your Microsoft ToDo password (password)
  • Path to your folder (/path/to/your/folder)
  • Path to the Chrome driver (/path/to/your/chromedriver)
Step 5: Run the Script

To run the script, simply execute the Bash script you created in Step 3:

bash todo.sh

You should now see the list of your Microsoft ToDo tasks printed in your terminal.

Conclusion

In this article, we have explored how to use Microsoft ToDo on Linux using Shell-Bash. Although it requires some set up, it is useful for programmers who want to manage their tasks on a Linux machine. With the help of automation tools like Selenium and Beautiful Soup, we can automate web applications and make them work on any platform.