Skip to content

maguitaria/puppeteer_automation

Repository files navigation

Certainly! Here's a README for your Puppeteer script:


Puppeteer Web Scraping Script

My small project about checking menu of Foodoo student`s restaurant at Oulu universite to get the downloaded menu and screenshot.

This is a Node.js script that uses Puppeteer, a headless browser automation tool, to scrape a webpage, capture a snapshot, take a screenshot, and extract text content from a specified webpage. It also includes a step to interact with the webpage by clicking on a specific element.

Prerequisites

Before running this script, make sure you have the following installed:

  • Node.js: You can download it from https://nodejs.org/.
  • npm (Node Package Manager): npm usually comes with Node.js.

Additionally, you will need to install the Puppeteer package:

npm install puppeteer

Usage

  1. Clone this repository or create a new Node.js project.

  2. Create a new JavaScript file (e.g., scrape.js) and copy the script into this file.

  3. Replace the URL in the script with the webpage you want to scrape:

    await page.goto("https://fi.jamix.cloud/apps/menu/?anro=93077&k=48&mt=89");
  4. Run the script using Node.js:

    node scrape.js

The script will perform the following actions:

  1. Launch a headless browser.
  2. Navigate to the specified webpage.
  3. Click on an element containing the text "English" using page.evaluate.
  4. Capture a snapshot of the webpage in MHTML format and save it as page.mhtml.
  5. Take a screenshot of the webpage and save it as screenshot.png.
  6. Extract the text content of the webpage and save it as foodoo_menu.txt.
  7. Close the browser.

You can customize the script for your specific use case or further process the captured data as needed.

Future enhancements

  • Add CSS locator for English menu and send it to email.
  • Go to each meal calories estimation and estimate what is the healthiest option.
  • Any suggestions?

License

This script is provided under the MIT License.


About

Puppeteer framework testing to get the menu of the day in fav restaurant automatically.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published