Skip to content

Instantly share code, notes, and snippets.

@erickclasen
Last active September 7, 2023 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erickclasen/babea42599df586ff6198bc68c6ad3c8 to your computer and use it in GitHub Desktop.
Save erickclasen/babea42599df586ff6198bc68c6ad3c8 to your computer and use it in GitHub Desktop.
This shell script is designed to periodically check a specific Dell Refurbished Clearance page for the availability of workstation towers with a minimum of 64GB RAM and no operating system (NO-OS). Runs a loop in the background cand be started using @reboot to the command on startup. Sends local email to the system, can be modified to do some ot…
#!/bin/bash
#-user-agent sets the User-Agent header in the HTTP request to mimic a web browser. In this example, it is set to simulate Google Chrome on Windows 10.
#--quiet suppresses unnecessary output from wget, showing only the content of the page.
#-O - redirects the output of wget to the standard output instead of saving it to a file.
#Not sure if user-agent is required or not, but playing it safe and assuming bots are not welcome.
# Figure out the pattern to the URL by selecting options and seeing what changes.
# For me I was looking for a min 64GB RAM, workstation tower, NO-OS.
# If you go to the page and play around with the checkboxes you can figure out
# the format of the query string patched onto the url to be able to filter.
# There was none when I looked so I selected 32GB to see the form of the URL to hen mangle it to 64GB.
URL="https://www.dellrefurbished.com/category/store-clear-ws/clearance/workstations/1.html?chassis_type[]=Tower&memory[]=64%20GB"
THRESHOLD=2000 # Adjust this value based on your preferences
EMAIL_ADDRESS="erick@localhost.com" # "your-email@example.com"
SLEEP_TIME=43200 #3600
while true; do
output=$(wget --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36" --quiet -O - "$URL")
line_count=$(echo "$output" | wc -l)
if [ $line_count -gt $THRESHOLD ]; then
echo "New machines are available on Dell Refurbished Clearance page!" | mail -s "Workstation Alert" $EMAIL_ADDRESS
fi
sleep $SLEEP_TIME # Sleep for SLEEP TIME secs before checking again
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment