From 447b8eec8f306e3a16b3d53723aee8ffc1805714 Mon Sep 17 00:00:00 2001 From: ruby109lol Date: Sat, 16 May 2020 23:19:25 +0800 Subject: [PATCH] add newest sort support(surugaya, mandarake, yahoo, mercari) --- secondhand.py | 70 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/secondhand.py b/secondhand.py index 447fc55..915fb21 100644 --- a/secondhand.py +++ b/secondhand.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -import sys, webbrowser +import sys +import webbrowser try: import urllib.parse as urlparse except ImportError: @@ -13,72 +14,91 @@ def open_browsers(event): product = productNameEntry.get() searchedArray = [] - if surugayaCheck.get() == True: - surugayaURL = "https://www.suruga-ya.jp/search?category=&search_word=" + urlparse.quote(product.encode('utf-8')) + surugayaURL = "https://www.suruga-ya.jp/search?category=&search_word=" + \ + urlparse.quote(product.encode('utf-8')) + if newestSort.get() == True: + surugayaURL = surugayaURL + "&rankBy=modificationTime%3Adescending" searchedArray.append(surugayaURL) if mandarakeCheck.get() == True: - mandarakeURL = "https://order.mandarake.co.jp/order/listPage/list?keyword=" + urlparse.quote(product.encode('utf-8')) + mandarakeURL = "https://order.mandarake.co.jp/order/listPage/list?keyword=" + \ + urlparse.quote(product.encode('utf-8')) + if newestSort.get() == True: + mandarakeURL = mandarakeURL + "&sort=arrival&sortOrder=1" searchedArray.append(mandarakeURL) if mercariCheck.get() == True: - mercariURL = "https://www.mercari.com/jp/search/?keyword=" + urlparse.quote(product.encode('utf-8')) + mercariURL = "https://www.mercari.com/jp/search/?keyword=" + \ + urlparse.quote(product.encode('utf-8')) + if newestSort.get() == True: + mercariURL = mercariURL + "&sort_order=created_desc" searchedArray.append(mercariURL) if yahooCheck.get() == True: - yahooURL = "https://auctions.yahoo.co.jp/search/search?auccat=&tab_ex=commerce&ei=utf-8&aq=-1&oq=&sc_i=&exflg=1&p=" + urlparse.quote(product.encode('utf-8')) + "&x=0&y=0" + yahooURL = "https://auctions.yahoo.co.jp/search/search?auccat=&tab_ex=commerce&ei=utf-8&aq=-1&oq=&sc_i=&exflg=1&p=" + \ + urlparse.quote(product.encode('utf-8')) + "&x=0&y=0" + if newestSort.get() == True: + yahooURL = yahooURL + "&new=1" searchedArray.append(yahooURL) if otamartCheck.get() == True: - otamartURL = "https://otamart.com/search/?keyword=" + urlparse.quote(product.encode('utf-8')) + otamartURL = "https://otamart.com/search/?keyword=" + \ + urlparse.quote(product.encode('utf-8'))  # otamart not support newest sort :-( searchedArray.append(otamartURL) for searchPage in searchedArray: webbrowser.open_new(searchPage) + window = tk.Tk() window.title('Second Hand') # window.geometry('500x500') productLabel = tk.Label(window, text='商品名') -productLabel.grid(row = 0, column = 0, sticky='w') +productLabel.grid(row=0, column=0, sticky='w') productNameEntry = tk.Entry(window) -productNameEntry.grid(row = 0, column = 1) +productNameEntry.grid(row=0, column=1) searchButton = tk.Button(window, text='Search') searchButton.bind('', open_browsers) -searchButton.grid(row = 0, column = 2) +searchButton.grid(row=0, column=2) surugayaCheck = tk.BooleanVar() -surugayaCheckButton = tk.Checkbutton(window, text = "Suruga-ya", variable = surugayaCheck, onvalue = True, offvalue = False, height = 0, width = 0) +surugayaCheckButton = tk.Checkbutton( + window, text="Suruga-ya", variable=surugayaCheck, onvalue=True, offvalue=False, height=0, width=0) surugayaCheckButton.select() -surugayaCheckButton.grid(row = 1, column = 0, sticky='w') +surugayaCheckButton.grid(row=1, column=0, sticky='w') mandarakeCheck = tk.BooleanVar() -mandarakeCheckButton = tk.Checkbutton(window, text = "Mandarake", variable = mandarakeCheck, onvalue = True, offvalue = False, height = 0, width = 0) +mandarakeCheckButton = tk.Checkbutton( + window, text="Mandarake", variable=mandarakeCheck, onvalue=True, offvalue=False, height=0, width=0) mandarakeCheckButton.select() -mandarakeCheckButton.grid(row = 1, column = 1) +mandarakeCheckButton.grid(row=1, column=1) mercariCheck = tk.BooleanVar() -mercariCheckButton = tk.Checkbutton(window, text = "Mercari", variable = mercariCheck, onvalue = True, offvalue = False, height = 0, width = 0) +mercariCheckButton = tk.Checkbutton( + window, text="Mercari", variable=mercariCheck, onvalue=True, offvalue=False, height=0, width=0) mercariCheckButton.select() -mercariCheckButton.grid(row = 2, column = 0, sticky='w') +mercariCheckButton.grid(row=2, column=0, sticky='w') yahooCheck = tk.BooleanVar() -yahooCheckButton = tk.Checkbutton(window, text = "Yahoo Auction", variable = yahooCheck, onvalue = True, offvalue = False, height = 0, width = 0) +yahooCheckButton = tk.Checkbutton( + window, text="Yahoo Auction", variable=yahooCheck, onvalue=True, offvalue=False, height=0, width=0) yahooCheckButton.select() -yahooCheckButton.grid(row = 2, column = 1) +yahooCheckButton.grid(row=2, column=1) otamartCheck = tk.BooleanVar() -otamartCheckButton = tk.Checkbutton(window, text = "Otamart", variable = otamartCheck, onvalue = True, offvalue = False, height = 0, width = 0) +otamartCheckButton = tk.Checkbutton( + window, text="Otamart", variable=otamartCheck, onvalue=True, offvalue=False, height=0, width=0) otamartCheckButton.select() -otamartCheckButton.grid(row = 3, column = 0, sticky='w') - -window.mainloop() - - - +otamartCheckButton.grid(row=2, column=2, sticky='w') +newestSort = tk.BooleanVar() +newestSortButton = tk.Checkbutton( + window, text="新品顺", variable=newestSort, onvalue=True, offvalue=False, height=0, width=0) +newestSortButton.select() +newestSortButton.grid(row=3, column=0, sticky='w') +window.mainloop()