Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # list2links.py
- # Works especially great for Firefox DownloadThemAll
- import re
- import tempfile
- import webbrowser
- try:
- # Python2
- from Tkinter import *
- from urllib2 import urlopen
- except ImportError:
- # Python3
- from tkinter import *
- from urllib.request import urlopen
- zmax=''
- srcfilename=tempfile.mktemp(".html", "demo_")
- web="""<!DOCTYPE html><b>@"""
- root=Tk()
- root.geometry('500x40+0+0')
- root.title('List-To-Links')
- Frame3=LabelFrame(root,height=30,borderwidth=0)
- Frame3.pack(fill=X)
- Frame3.pack_propagate(False)
- def convert2jpg():
- links=root.clipboard_get()
- links=links.split('\n')
- urls=[]
- for link in links:
- if link: urls.append("<a href='"+link+"'>"+link+"</a>")
- if urls:
- links='<br><br>'.join(urls)
- temp=open(srcfilename, 'w')
- temp.write(web.replace('@',links))
- temp.close()
- webbrowser.open_new_tab(srcfilename)
- #
- cpb=Button(Frame3,text="Links",width=16,command=convert2jpg)
- cpb.pack(side=LEFT)
- lbl=Label(Frame3)
- lbl.pack(side=LEFT)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement