Skip to content

Instantly share code, notes, and snippets.

@underyx
Last active November 9, 2018 11:20
Show Gist options
  • Save underyx/64f10989d272f2e05dbfbf0c5028740a to your computer and use it in GitHub Desktop.
Save underyx/64f10989d272f2e05dbfbf0c5028740a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import os
from requests_html import HTMLSession
session = HTMLSession()
webhook_url = os.environ["SLACK_WEBHOOK_URL"]
r = session.get("https://www.czc.cz/sony%20wh-1000xm2/hledat")
r.raise_for_status()
tiles = r.html.find(".new-tile")
print(tiles)
price = min(
int(
tile.find(".price .price-vatin", first=True)
.text.replace("\xa0", "")
.replace("Kč", "")
)
for tile in tiles
)
print(price)
if price != 7790:
r = session.post(
webhook_url,
json={
"text": "@bence buy the headphones, their price changed! https://www.czc.cz/sony%20wh-1000xm2/hledat",
"link_names": True,
},
)
r.raise_for_status()
print(r.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment