Advertisement
here2share

# Tk_list_reclaim.py ZZZ

Jul 20th, 2016
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.52 KB | None | 0 0
  1. # Tk_list_reclaim.py ZZZ
  2.  
  3. import urllib
  4. import re
  5. import tempfile
  6. import webbrowser
  7.  
  8. srcfilename=tempfile.mktemp(".html", "demo_")
  9. web="""<!DOCTYPE html>
  10. <html>
  11. <body><p><b>@</p></body>
  12. </html>"""
  13.  
  14. try:
  15.     # Python2
  16.     from Tkinter import *
  17.     from urllib2 import urlopen
  18. except ImportError:
  19.     # Python3
  20.     from tkinter import *
  21.     from urllib.request import urlopen
  22.  
  23. root=Tk()
  24. root.geometry('400x40+0+0')
  25. root.title('list reclaim')
  26.  
  27. Frame3=LabelFrame(root,height=30,borderwidth=0)
  28. Frame3.pack(fill=X)
  29. Frame3.pack_propagate(False)
  30.  
  31. zzz='''
  32. www.website1.com/images...logo-2.jpg
  33. www.website1.com/images...logo-14.jpg
  34. www.website4.com/images...logo-6.jpg
  35. www.website6.com/images...logo-7.jpg
  36. www.website7.com/images...logo-14.jpg
  37. www.website9.com/images...logo-18.jpg
  38. '''.split('\n')
  39. #
  40. def from_clipboard():
  41.     global zzz
  42.     crawled_urls = []
  43.     def dblchk(z):
  44.         if z not in crawled_urls:
  45.             crawled_urls.append(z)
  46.     url = root.clipboard_get()
  47.     url=url.replace('.jpg','.jpg@@@')
  48.     url=url.split('@@@')
  49.     for z in zzz:
  50.         v=0
  51.         for c in url:
  52.             if '...' in z:
  53.                 a,b=z.split('...')
  54.                 if a in c and b in c:
  55.                     dblchk(c)
  56.                     v=1
  57.             else:
  58.                 dblchk(z)
  59.                 v=2
  60.         if v is 0: print z
  61.        
  62.     if crawled_urls:
  63.         temp=open(srcfilename, 'w')
  64.         zzz='<br>'.join(crawled_urls)
  65.         temp.write(web.replace('@',zzz))
  66.         temp.close()
  67.         webbrowser.open_new_tab(srcfilename)
  68. #
  69.  
  70. cpb=Button(Frame3,text="Clipboard",width=16,command=from_clipboard)
  71. cpb.pack(side=LEFT)
  72.  
  73. lbl=Label(Frame3)
  74. lbl.pack(side=LEFT)
  75.  
  76. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement