Advertisement
here2share

# list2links.py

Nov 18th, 2016
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. # list2links.py
  2. # Works especially great for Firefox DownloadThemAll
  3.  
  4. import re
  5. import tempfile
  6. import webbrowser
  7.  
  8. try:
  9.     # Python2
  10.     from Tkinter import *
  11.     from urllib2 import urlopen
  12. except ImportError:
  13.     # Python3
  14.     from tkinter import *
  15.     from urllib.request import urlopen
  16.  
  17. zmax=''
  18. srcfilename=tempfile.mktemp(".html", "demo_")
  19. web="""<!DOCTYPE html><b>@"""
  20.  
  21. root=Tk()
  22. root.geometry('500x40+0+0')
  23. root.title('List-To-Links')
  24.  
  25. Frame3=LabelFrame(root,height=30,borderwidth=0)
  26. Frame3.pack(fill=X)
  27. Frame3.pack_propagate(False)
  28.  
  29.  
  30. def convert2jpg():
  31.     links=root.clipboard_get()
  32.     links=links.split('\n')
  33.     urls=[]
  34.     for link in links:
  35.         if link: urls.append("<a href='"+link+"'>"+link+"</a>")
  36.     if urls:
  37.         links='<br><br>'.join(urls)
  38.         temp=open(srcfilename, 'w')
  39.         temp.write(web.replace('@',links))
  40.         temp.close()
  41.         webbrowser.open_new_tab(srcfilename)
  42. #
  43.  
  44.  
  45. cpb=Button(Frame3,text="Links",width=16,command=convert2jpg)
  46. cpb.pack(side=LEFT)
  47.  
  48. lbl=Label(Frame3)
  49. lbl.pack(side=LEFT)
  50.  
  51. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement