News report update and saved in excel file assignment
A desktop automation script that uses PyAutoGUI to open a news site in Chrome, copy text from the page, paste it into Excel alongside a timestamp, and save a dated workbook — all by driving the real mouse and keyboard.
This is GUI automation, not web scraping. The script does not use an HTTP client or a browser driver. It sends literal keystrokes and mouse clicks to whatever is on screen, exactly as a person would. That makes it a useful exercise in automating applications that expose no API, and a good demonstration of why that approach is fragile.
What it does Step Action 1 Win+R → type chrome → Enter, then Ctrl+T for a new tab 2 Type https://indianexpress.com/ and press Enter 3 Move to a fixed screen coordinate, triple-click to select a text block, Ctrl+C, then Ctrl+W to close the tab 4 Win+R → type excel → Enter 5 Type the current timestamp, Tab, paste the copied text, Tab, type a source label 6 Capture a full-screen screenshot to daily_report_screenshot.png 7 Ctrl+S, type daily_report_, Enter
Safety settings: FAILSAFE = True (slam the cursor into a screen corner to abort) and PAUSE = 0.5 (half-second gap between every PyAutoGUI call).
Requirements Windows — the script uses Win+R and launches Chrome and Excel by name Python 3.12 Google Chrome and Microsoft Excel installed A 2880×1800 display, or you will need to change the click coordinates bash pip install pyautogui pyscreenshot pyscreeze pillow Running it bash python pyautogui-daily-report-bot.py
Then do not touch the mouse or keyboard. The script types into whatever window has focus. Anything you click during the run redirects its keystrokes somewhere unintended.
To abort mid-run, throw the mouse cursor into a corner of the screen — FAILSAFE raises an exception and stops execution.
Output File Contents daily_report_.xlsx Three columns: timestamp, copied text, source label daily_report_screenshot.png Full-screen capture taken just before saving
The workbook is saved to Excel's default save location, not the repository folder.
Sample output — and what it reveals
The committed run produced a single row:
A B C 2026-07-23 08:35:44 Cloud Current affairs : news from indianexpress.com
Column B should hold a news headline or article text. It holds the word Cloud — the triple-click at coordinate (500, 400) landed on a weather widget rather than on any article. The script completed every step without error and still captured the wrong thing.
That is the honest lesson of the exercise: coordinate-based automation has no idea what it is clicking. There is no selector, no element, no assertion — just a pixel position and the hope that the page laid out the way it did last time. Change the screen resolution, the window size, the ad placement, or the site's layout, and the script keeps running happily while collecting garbage.
Known issues Hardcoded coordinates. pyautogui.moveTo(500, 400) assumes a specific resolution and page layout. This is the root cause of the wrong-content capture above. Fixed time.sleep() waits. One to two seconds per step. On a slow network the page will not have loaded and the click hits an empty page; on a fast machine the waits are dead time. Stale comment. Step 2 prints load Groww site but the script loads indianexpress.com — left over from an earlier version of the exercise. Unused imports. pyscreenshot and pyscreeze are imported but never called. pyautogui.screenshot() handles the capture. No error handling. If Chrome or Excel is slow to open, or Excel shows a "start screen" instead of a blank workbook, the keystrokes go to the wrong place and the run silently corrupts. The save step assumes a fresh workbook. Ctrl+S on an already-saved file skips the filename prompt, so the typed filename would be entered into a cell instead. Windows-only. No macOS or Linux path. Repository contents daily-report-bot/ ├── pyautogui-daily-report-bot.py # The script ├── daily_report_2026-07-23.xlsx # Sample output ├── daily_report_screenshot.png # Sample screenshot ├── Day 3 assignment pyautogui.zip # 12 MB — screen recording of a run ├── pyvenv.cfg # Machine-specific, should not be committed └── README.md Possible next steps Replace the triple-click with a real scrape — requests plus BeautifulSoup gets the headline reliably in three lines and removes every coordinate from the script If GUI automation is the point, use pyautogui.locateOnScreen() with reference images instead of raw coordinates Write the Excel file directly with openpyxl rather than driving the Excel UI Replace time.sleep() with a wait-until-condition helper Add a validation step: if the copied text is under N characters, fail loudly instead of saving it Wrap the run in try/except and log which step failed