Improved overall performance
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 111 KiB |
@@ -11,6 +11,8 @@ from genericpath import isfile
|
|||||||
from pyautogui import size
|
from pyautogui import size
|
||||||
from google.cloud import vision
|
from google.cloud import vision
|
||||||
|
|
||||||
|
from web_search import search_maker
|
||||||
|
|
||||||
# Minimum score required for labels detection
|
# Minimum score required for labels detection
|
||||||
MIN_SCORE_REQUIRED = 0.80
|
MIN_SCORE_REQUIRED = 0.80
|
||||||
|
|
||||||
@@ -38,6 +40,8 @@ def make_query():
|
|||||||
else:
|
else:
|
||||||
labels_str = request[1]
|
labels_str = request[1]
|
||||||
colors_str = request[2]
|
colors_str = request[2]
|
||||||
|
|
||||||
|
search_maker.search(command, option, labels_str, colors_str)
|
||||||
|
|
||||||
def shape_selection(event, x, y, flags, param):
|
def shape_selection(event, x, y, flags, param):
|
||||||
# grab references to the global variables
|
# grab references to the global variables
|
||||||
@@ -208,6 +212,6 @@ for color_info in filtered_colors:
|
|||||||
'\tColor Name: ' + color_name +
|
'\tColor Name: ' + color_name +
|
||||||
'\n')
|
'\n')
|
||||||
|
|
||||||
create_query()
|
make_query()
|
||||||
#queries = ["test", "search"]
|
#queries = ["test", "search"]
|
||||||
#google_search(queries)
|
#google_search(queries)
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
import webbrowser
|
|
||||||
|
|
||||||
def join_data(labels = [], colors = []):
|
|
||||||
for i in range(len(labels)):
|
|
||||||
label_joint = "+".join(labels[i])
|
|
||||||
for j in range(len(colors)):
|
|
||||||
color_joint = "+".join(colors[j])
|
|
||||||
|
|
||||||
return label_joint + " " + color_joint
|
|
||||||
|
|
||||||
def generate_url(keywords):
|
|
||||||
url = "https://www.amazon.it/s?k="
|
|
||||||
|
|
||||||
return url + keywords
|
|
||||||
|
|
||||||
def amazon_search(labels, colors):
|
|
||||||
keyword_list = join_data(labels, colors)
|
|
||||||
|
|
||||||
# C'mon Jeffrey you can do it!
|
|
||||||
jeff_net = generate_url(keyword_list)
|
|
||||||
webbrowser.open(jeff_net)
|
|
||||||
print(jeff_net)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
amazon_search([""], [""])
|
|
||||||
|
|
||||||
|
|
||||||
## NOTHING TO SEE HERE...
|
|
||||||
#lbl = ["jeff", "besos", "halloween", "costume"]
|
|
||||||
#clr = ["orange"]
|
|
||||||
#amazon_search([lbl], [clr])
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
import webbrowser
|
|
||||||
|
|
||||||
def join_data(labels = [], colors = []):
|
|
||||||
for i in range(len(labels)):
|
|
||||||
label_joint = "+".join(labels[i])
|
|
||||||
for j in range(len(colors)):
|
|
||||||
color_joint = "+".join(colors[j])
|
|
||||||
|
|
||||||
return label_joint + " " + color_joint
|
|
||||||
|
|
||||||
def generate_url(keywords, search_type):
|
|
||||||
if search_type == '--shopping':
|
|
||||||
pre_url = "https://www.google.com/search?q="
|
|
||||||
post_url = "h&source=lmns&tbm=shop"
|
|
||||||
|
|
||||||
return pre_url + keywords + post_url
|
|
||||||
elif search_type == '--images':
|
|
||||||
pre_url = "https://www.google.com/search?q="
|
|
||||||
post_url = "&newwindow=1&tbm=isch&source=lnms"
|
|
||||||
|
|
||||||
return pre_url + keywords + post_url
|
|
||||||
else:
|
|
||||||
url = "https://www.google.com/search?q="
|
|
||||||
|
|
||||||
return url + keywords
|
|
||||||
|
|
||||||
def google_search(labels, colors, search_type):
|
|
||||||
keyword_list = join_data(labels, colors)
|
|
||||||
print(keyword_list)
|
|
||||||
url = generate_url(keyword_list, search_type)
|
|
||||||
webbrowser.open(url)
|
|
||||||
print(url)
|
|
||||||
|
|
||||||
|
|
||||||
## TEST ZONE - KEEP AWAY!
|
|
||||||
#lbl = ["shirt", "long", "sleeve"]
|
|
||||||
#clr = ["blue", "light"]
|
|
||||||
#google_search([lbl], [clr], "--images")
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import webbrowser
|
||||||
|
|
||||||
|
def join_data(labels = str, colors = str):
|
||||||
|
keyword = labels + "+" + colors
|
||||||
|
|
||||||
|
return keyword
|
||||||
|
|
||||||
|
def generate_url(browser, option, keywords):
|
||||||
|
if browser == "google":
|
||||||
|
if option == '-shopping':
|
||||||
|
pre_url = "https://www.google.com/search?q="
|
||||||
|
post_url = "&source=lmns&tbm=shop"
|
||||||
|
|
||||||
|
return pre_url + keywords + post_url
|
||||||
|
elif option == '-images':
|
||||||
|
pre_url = "https://www.google.com/search?q="
|
||||||
|
post_url = "&newwindow=1&tbm=isch&source=lnms"
|
||||||
|
|
||||||
|
return pre_url + keywords + post_url
|
||||||
|
else:
|
||||||
|
url = "https://www.google.com/search?q="
|
||||||
|
|
||||||
|
elif browser == "amazon":
|
||||||
|
url = "https://www.amazon.it/s?k="
|
||||||
|
|
||||||
|
return url + keywords
|
||||||
|
|
||||||
|
def search(browser, option, labels, colors):
|
||||||
|
keywords = join_data(labels, colors)
|
||||||
|
print(keywords)
|
||||||
|
url = generate_url(browser, option, keywords)
|
||||||
|
webbrowser.open(url)
|
||||||
|
print(url)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
browser = "google"
|
||||||
|
option = "-shopping"
|
||||||
|
labels = "shirt+long+sleeve"
|
||||||
|
colors = "blue\n"
|
||||||
|
search(browser, option, labels, colors)
|
||||||
Reference in New Issue
Block a user