Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # Tk_google_images_sort_by_height.py
- import re
- import tempfile
- import webbrowser
- import random
- try:
- # Python2
- from Tkinter import *
- from urllib2 import urlopen
- except ImportError:
- # Python3
- from tkinter import *
- from urllib.request import urlopen
- #
- srcfilename=tempfile.mktemp(".html", "demo_")
- root=Tk()
- root.geometry('500x40+0+0')
- root.title('Google Images Sort By Height')
- Frame3=LabelFrame(root,height=30,borderwidth=0)
- Frame3.pack(fill=X)
- Frame3.pack_propagate(False)
- web="""<html>
- <head></head>
- <body>@</body>
- </html>"""
- top=[[5120, 3200],
- [1800, 3200],
- [4096, 3072],
- [4500, 3000],
- [2000, 3000],
- [1440, 2960],
- [5120, 2880],
- [1800, 2880],
- [1620, 2880],
- [1440, 2880],
- [900, 2880],
- [1920, 2560],
- [1800, 2560],
- [1700, 2560],
- [1600, 2560],
- [1440, 2560],
- [1080, 2560],
- [1080, 2538],
- [1125, 2436],
- [3840, 2400],
- [3200, 2400],
- [1440, 2304],
- [5120, 2160],
- [4096, 2160],
- [3840, 2160],
- [3240, 2160],
- [1440, 2160],
- [1080, 2160],
- [2800, 2100],
- [3200, 2048],
- [2732, 2048],
- [2560, 2048],
- [1536, 2048],
- [1280, 2048],
- [1152, 2048],
- [1080, 2048],
- [3000, 2000],
- [2000, 2000],
- [2560, 1920],
- [1920, 1920],
- [1440, 1920],
- [1400, 1920],
- [1280, 1920],
- [1200, 1920],
- [1080, 1920],
- [1392, 1856],
- [2736, 1824],
- [3200, 1800],
- [2880, 1800],
- [2560, 1800],
- [1800, 1800],
- [1440, 1800],
- [1344, 1792],
- [1000, 1776],
- [2304, 1728],
- [2560, 1700],
- [1700, 1700],
- [1050, 1680],
- [2880, 1620],
- [1620, 1620],
- [3840, 1600],
- [2560, 1600],
- [1600, 1600],
- [1280, 1600],
- [1200, 1600],
- [1024, 1600],
- [900, 1600],
- [768, 1600],
- [2048, 1536],
- [2256, 1504],
- [3440, 1440],
- [2960, 1440],
- [2880, 1440],
- [2560, 1440],
- [2304, 1440],
- [2160, 1440],
- [1920, 1440],
- [1800, 1440],
- [1440, 1440],
- [1080, 1440],
- [1024, 1440],
- [960, 1440],
- [900, 1440],
- [1920, 1400],
- [1400, 1400],
- [1050, 1400],
- [1856, 1392],
- [768, 1366],
- [1792, 1344],
- [750, 1334],
- [2048, 1280],
- [1920, 1280],
- [1600, 1280],
- [1280, 1280],
- [1024, 1280],
- [960, 1280],
- [854, 1280],
- [800, 1280],
- [768, 1280],
- [1920, 1200],
- [1600, 1200],
- [1200, 1200],
- [1080, 1200],
- [800, 1200],
- [2048, 1152],
- [1152, 1152],
- [900, 1152],
- [864, 1152],
- [768, 1152],
- [2436, 1125],
- [1125, 1125],
- [832, 1120],
- [2560, 1080],
- [2538, 1080],
- [2160, 1080],
- [2048, 1080],
- [1920, 1080],
- [1440, 1080],
- [1200, 1080],
- [1080, 1080],
- [1680, 1050],
- [1400, 1050],
- [1050, 1050],
- [1600, 1024],
- [1440, 1024],
- [1280, 1024],
- [1024, 1024],
- [800, 1024],
- [768, 1024],
- [1776, 1000],
- [1000, 1000],
- [1440, 960],
- [1280, 960],
- [960, 960],
- [2880, 900],
- [1600, 900],
- [1440, 900],
- [1152, 900],
- [900, 900],
- [1152, 864],
- [864, 864],
- [1280, 854],
- [854, 854],
- [1120, 832],
- [832, 832],
- [1280, 800],
- [1200, 800],
- [1024, 800],
- [800, 800],
- [1600, 768],
- [1366, 768],
- [1280, 768],
- [1152, 768],
- [1024, 768],
- [768, 768],
- [1334, 750],
- [750, 750]]
- def cpbd():
- data=root.clipboard_get()
- xfor='Search results for '
- try:
- x1=data.index(xfor)
- x2=data.index(' on Yandex.Images')
- except:
- print "Invalid Entry"
- return '',[]
- search=data[x1+len(xfor):x2]
- for z in '& amp;'.split():
- search=search.replace(z,'')
- search=search.replace('quot;','"')[1:-1]
- print search
- return search, data.split('.jpg","fileSizeInBytes":')[1:]
- #
- def hyperlinks():
- def xypx(x,y):
- if [x,y] not in ttt:
- print x,y
- print
- ttt.append([x,y])
- search,urls=cpbd()
- ttt=top[:]
- if urls:
- for url in urls:
- url=url.split('}')[0]
- url=url.replace(',"w":','@')
- url=url.replace(',"h":','@')
- url=url.split('@')
- w=int(url[1])
- h=int(url[2])
- if h > 749 and w > 249:
- xypx(w,h)
- if w > 749: xypx(h,w)
- 0
- b='https://www.google.ca/search?q='
- ttt.sort()
- for t in range(len(ttt)):
- h,w=ttt[t]
- q=search.replace(' ','+')
- q=q.replace('"','%22')
- # if 'inurl:' not in q: q='inurl:'+q
- ttt[t]='<a href="{0}{3}&tbs=isz:ex,iszw:{1},iszh:{2}&tbm=isch" target="_blank">{1}x{2}</a> * abroad'.format(b,w,h,q) # alt to target="_self"
- ttt.append(ttt[t].replace(q,'inurl:'+q).replace('</a> * abroad','</a>'))
- 0
- urls='<br>'.join(ttt[::-1])
- temp=open(srcfilename, 'w')
- temp.write(web.replace('@',urls))
- temp.close()
- webbrowser.open_new_tab(srcfilename)
- #
- cpb=Button(Frame3,text="Links",width=16,command=hyperlinks)
- cpb.pack(side=LEFT)
- lbl=Label(Frame3)
- lbl.pack(side=LEFT)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement