Skip to content

Instantly share code, notes, and snippets.

@Lokaltog
Created July 25, 2016 08:30
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 Lokaltog/5761338dfe4471fecfc72f7842722742 to your computer and use it in GitHub Desktop.
Save Lokaltog/5761338dfe4471fecfc72f7842722742 to your computer and use it in GitHub Desktop.
Tired of the Norwegian postal service (Posten/Bring) tagging shipments as "attempted delivered, nobody present/unknown address" without actually attempting to deliver the package? This script monitors the package tracking page and plays a siren sound/alert when the status changes. You can then call customer support and complain at +4721316234, i…
#!/usr/bin/env python
'''
Tired of the Norwegian postal service (Posten/Bring) tagging shipments as
"attempted delivered, nobody present/unknown address" without actually
attempting to deliver the package? This script monitors the package tracking
page and plays a siren sound/alert when the status changes. You can then call
customer support and complain at +4721316234, if you're lucky they'll call the
delivery driver and tell him to return and actually deliver the package.
Requires requests and BeautifulSoup to run.
'''
import subprocess
import sys
import time
import requests
from bs4 import BeautifulSoup
while True:
r = requests.get('http://sporing.bring.no/sporing.html', params=dict(q=sys.argv[1]))
soup = BeautifulSoup(r.text, 'html.parser')
tooltip = soup.find_all('span', rel='tooltip')[0].string
if tooltip != 'Sendingen er lastet opp for utkjøring':
print('Fuck Posten/Bring!')
subprocess.run(['mpv', 'siren.mp3'])
break
sys.stdout.write('.')
sys.stdout.flush()
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment