Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_pinterest_monthly_link_automator.py
- # as launched March 2010
- try:
- # Python2
- from Tkinter import *
- from urllib2 import urlopen
- except ImportError:
- # Python3
- from tkinter import *
- from urllib.request import urlopen
- import webbrowser
- import time
- from datetime import datetime, timedelta
- import tempfile
- srcfilename=tempfile.mktemp(".html", "demo_")
- web="""<!DOCTYPE html><b>@"""
- root=Tk()
- root.geometry('270x24+0+0')
- root.title('Pinterest Monthly')
- w='300'
- h='750'
- def url_text():
- html='https://www.google.ca/search?q=site%3Apinterest.com+glamour+face'
- td=datetime.now()
- # max='%s-%s-%s' %(td.year,td.month,td.day)
- links=[]
- line=''
- mm=td.month
- yy=td.year
- while 1:
- mm-=1
- if not mm:
- mm=12
- yy-=1
- if (yy <= 2010 and mm < 3) or len(links) > 10000: break
- ttt='%02d-%02d' %(yy,mm)
- tmp=html+'&hl=en&biw=1361&bih=604&tbs=cdr:1,cd_min:'+ttt+'-01,cd_max:'+ttt+'-15,isz:l&tbm=isch'
- tmp="<a href='"+tmp+"'>"+ttt+"</a> "
- tx=datetime(yy,mm,1)+timedelta(days=32)
- tx=str(datetime(tx.year,tx.month,1)-timedelta(days=1))[:10]
- ttt=html+'&hl=en&biw=1361&bih=604&tbs=cdr:1,cd_min:'+ttt+'-16,cd_max:'+tx+',isz:l&tbm=isch'
- line+=tmp+"<a href='"+ttt+"'>+</a>"
- if mm in (1,7):
- links.append(line); line=''
- else: line+=' '
- print len(links)
- links='<br><br>'.join(links)
- temp=open(srcfilename, 'w')
- temp.write(web.replace('@',links))
- temp.close()
- webbrowser.open_new_tab(srcfilename)
- #
- btn=Button(root,text="Show List",width=8,command=url_text)
- btn.pack(side=LEFT)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement