LuckyEgg Posted September 6, 2016 Report Posted September 6, 2016 (edited) Python 2.7 - Requests - lxml.html - libnotify *Merge doar pe linux Apare notificare cand se posteaza ceva topic nou pe rst SOURCECODE: https://github.com/pukapy/newsRST Edited September 6, 2016 by LuckyEgg 2 Quote
Active Members MrGrj Posted September 6, 2016 Active Members Report Posted September 6, 2016 Mi-am aruncat si eu un ochi repede. Nu am testat: import requests from lxml import html from gi.repository import Notify, GdkPixbuf from time import sleep s = requests.session() def get_news(): """ Return the last topic """ page = s.get("https://rstforums.com") tree = html.fromstring(page.content) subject = tree.xpath('//a[@class="postTitle"]/text()') title = tree.xpath('//span[@class="author"]/text()') topic = "Subject: {0} -- Posted by: {1}".format(subject[0], title[0]) return topic def get_notification(x): """ Show notification """ Notify.init("RST News") notification = Notify.Notification.new("New post on rstforums.com!", x) image = GdkPixbuf.Pixbuf.new_from_file("rst.png") notification.set_icon_from_pixbuf(image) notification.set_image_from_pixbuf(image) notification.show() def main(): last_new = [] while True: try: last_message = get_news() except: print("error - ce error ? tre' sa ghicesc ?\n") continue if last_message != last_new: last_new = last_message get_notification(last_message) sleep(3) if __name__ == '__main__': main() - calea catre imagine as pune-o ca argument - ce ofera nou asta spre deosebire de un feed ? Spor in continuare, e un inceput bun Citeste PEP8 ! Quote
LuckyEgg Posted September 6, 2016 Author Report Posted September 6, 2016 Nu ofera prea multe.. dar l-am facut sa vad daca il pot face si daca ma descurc. Cine primeste eroarea "DBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name :1.221 was not provided by any .service files" sa deie sudo apt-get install libnotify-cil-dev Quote