Created
March 11, 2015 12:38
-
-
Save mikroskeem/368eaccccc7ea4819fb9 to your computer and use it in GitHub Desktop.
Displays fortune on login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Desktop Entry] | |
Type=Application | |
Name=Fortune notification | |
Comment=Fortune in notification | |
Exec=/home/mark/bin/fortune.py | |
OnlyShowIn=GNOME; | |
X-GNOME-Autostart-Phase=Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests, json | |
from bs4 import BeautifulSoup | |
from gi.repository import Notify | |
Notify.init("Today's fortune") | |
headers = {"User-Agent": "curl/7.41.0", "Referer": "http://www.myfortunecookie.co.uk/"} | |
r = requests.post("http://www.myfortunecookie.co.uk/starsol.php", data={'t': 'fortune'}, headers=headers) | |
soup = BeautifulSoup(r.text) | |
FortuneNotif=Notify.Notification.new("Today's fortune", soup.body.h1.div.text, "dialog-information") | |
FortuneNotif.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment