Advertisement
Guest User

Untitled

a guest
Nov 13th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.17 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import smtplib
  3. import urllib2
  4. import random
  5. import re
  6. import time
  7.  
  8. #panou de configurare
  9. email = ""   #unde vrei sa primesti ofertele
  10. smtp = "my.inbox.com"
  11. loginuser = "@inbox.com"
  12. loginpass = ""
  13. <span class="highlight">chilipir</span> = 25    #pretul(ron) sub care sunteti anuntat
  14. interval_timp_cautare = 600 # in secunde
  15.  
  16. print r"""
  17. #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#\
  18. #.........RSTforums.com........#-\
  19. #.............Usr6.............#--\/
  20. #...Cautatoru de chilipiruri...#--/\
  21. #..............................#-/
  22. #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#/
  23. """
  24. def email_sender(TEXT):
  25.     #print TEXT
  26.     message = 'To:' + email + '\n' + 'From: ' + loginuser + '\n' + 'Subject:Chilipir \n\n' + TEXT
  27.     server = smtplib.SMTP(smtp, 587)
  28.     server.login(loginuser, loginpass )
  29.     server.sendmail(loginuser, email, message)
  30.     server.quit()
  31.     print "Oferta a fost expediata"
  32.     return
  33.  
  34. expediate = []
  35. while True :
  36.     expediat = ""
  37.     random_nr = str(random.randint(10**16,99999999999999999))
  38.     ua = "Opera/%s.%s (Windows NT %s.%s) Presto/%s.%s.%s Version/%s.%s" \
  39.             %(random_nr[0], random_nr[1:3], random_nr[4], random_nr[5], random_nr[6], random_nr[7:9], random_nr[10:13], random_nr[13:15], random_nr[15:17])
  40.     try:
  41.         site = "http://www.emag.ro/resigilate/sort-priceasc"
  42.         req = urllib2.Request(site, None, {'User-Agent' : ua})
  43.         continut = urllib2.urlopen(req, timeout=30).read()
  44.         match = re.findall('\"money-int\"\>(\d*)\<\/span\>\<sup class=\"money-decimal\"\>\d*.+\n.+\t+.+\n\t.+\n.+\n.+\<a href=\"(.+#resigilate)"',continut)
  45.         for every in match:
  46.             pret, link = every
  47.             if int(pret) <= <span class="highlight">chilipir</span>:
  48.                 link = "http://www.emag.ro" + link
  49.                 unic = str(pret) + link
  50.                 if unic not in expediate:
  51.                     expediat += str(pret) + "\t" + link +"\n"
  52.                     expediate.append(unic)
  53.     except Exception as E:
  54.         email_sender(str(E))
  55.     if len(expediat) >= 1:
  56.         email_sender(expediat)
  57.     time.sleep(interval_timp_cautare)
  58.     print time.strftime("%c"), "nimic nou"
  59. exit()
  60.  
  61. priN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement