Skip to content

Instantly share code, notes, and snippets.

@szepeviktor
Last active July 20, 2020 16:59
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 szepeviktor/252591058a0f9a1163cbfb07216b8a1d to your computer and use it in GitHub Desktop.
Save szepeviktor/252591058a0f9a1163cbfb07216b8a1d to your computer and use it in GitHub Desktop.
Marseus.hu HP WorkStation figyelő
#!/bin/bash
EXPECTED_HASH=1c9f2c2b7e9879a5a5cda6cb550710f55b3caa48
Get_product_titles()
{
# Download page, fix ampersands, convert to XML, parse product titles
wget -qO- https://www.marseus.hu/hu/szamitogep/workstation/hp/ \
| sed -e 's/&\([a-z_]\+\=\)/\&\1/g' \
| xmlstarlet fo --html --recover 2>/dev/null \
| xmlstarlet sel --template --value-of '//div[@class="product_list "]//h2/a'
}
CURRENT_TITLES="$(Get_product_titles)"
CURRENT_HASH="$(echo "${CURRENT_TITLES}" | shasum | cut -d " " -f 1)"
if [ "${EXPECTED_HASH}" == "${CURRENT_HASH}" ]; then
exit 0
fi
echo "HP Workstation érkezett. (${CURRENT_HASH})
https://www.marseus.hu/hu/szamitogep/workstation/hp/
${CURRENT_TITLES}" 1>&2
exit 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment