Skip to content

Commit 447b8ee

Browse files
committed
add newest sort support(surugaya, mandarake, yahoo, mercari)
1 parent 11acdaa commit 447b8ee

File tree

1 file changed

+45
-25
lines changed

1 file changed

+45
-25
lines changed

secondhand.py

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

3-
import sys, webbrowser
3+
import sys
4+
import webbrowser
45
try:
56
import urllib.parse as urlparse
67
except ImportError:
@@ -13,72 +14,91 @@ def open_browsers(event):
1314
product = productNameEntry.get()
1415
searchedArray = []
1516

16-
1717
if surugayaCheck.get() == True:
18-
surugayaURL = "https://www.suruga-ya.jp/search?category=&search_word=" + urlparse.quote(product.encode('utf-8'))
18+
surugayaURL = "https://www.suruga-ya.jp/search?category=&search_word=" + \
19+
urlparse.quote(product.encode('utf-8'))
20+
if newestSort.get() == True:
21+
surugayaURL = surugayaURL + "&rankBy=modificationTime%3Adescending"
1922
searchedArray.append(surugayaURL)
2023

2124
if mandarakeCheck.get() == True:
22-
mandarakeURL = "https://order.mandarake.co.jp/order/listPage/list?keyword=" + urlparse.quote(product.encode('utf-8'))
25+
mandarakeURL = "https://order.mandarake.co.jp/order/listPage/list?keyword=" + \
26+
urlparse.quote(product.encode('utf-8'))
27+
if newestSort.get() == True:
28+
mandarakeURL = mandarakeURL + "&sort=arrival&sortOrder=1"
2329
searchedArray.append(mandarakeURL)
2430

2531
if mercariCheck.get() == True:
26-
mercariURL = "https://www.mercari.com/jp/search/?keyword=" + urlparse.quote(product.encode('utf-8'))
32+
mercariURL = "https://www.mercari.com/jp/search/?keyword=" + \
33+
urlparse.quote(product.encode('utf-8'))
34+
if newestSort.get() == True:
35+
mercariURL = mercariURL + "&sort_order=created_desc"
2736
searchedArray.append(mercariURL)
2837

2938
if yahooCheck.get() == True:
30-
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"
39+
yahooURL = "https://auctions.yahoo.co.jp/search/search?auccat=&tab_ex=commerce&ei=utf-8&aq=-1&oq=&sc_i=&exflg=1&p=" + \
40+
urlparse.quote(product.encode('utf-8')) + "&x=0&y=0"
41+
if newestSort.get() == True:
42+
yahooURL = yahooURL + "&new=1"
3143
searchedArray.append(yahooURL)
3244

3345
if otamartCheck.get() == True:
34-
otamartURL = "https://otamart.com/search/?keyword=" + urlparse.quote(product.encode('utf-8'))
46+
otamartURL = "https://otamart.com/search/?keyword=" + \
47+
urlparse.quote(product.encode('utf-8'))  # otamart not support newest sort :-(
3548
searchedArray.append(otamartURL)
3649

3750
for searchPage in searchedArray:
3851
webbrowser.open_new(searchPage)
3952

53+
4054
window = tk.Tk()
4155
window.title('Second Hand')
4256
# window.geometry('500x500')
4357

4458
productLabel = tk.Label(window, text='商品名')
45-
productLabel.grid(row = 0, column = 0, sticky='w')
59+
productLabel.grid(row=0, column=0, sticky='w')
4660

4761
productNameEntry = tk.Entry(window)
48-
productNameEntry.grid(row = 0, column = 1)
62+
productNameEntry.grid(row=0, column=1)
4963

5064
searchButton = tk.Button(window, text='Search')
5165
searchButton.bind('<Button-1>', open_browsers)
52-
searchButton.grid(row = 0, column = 2)
66+
searchButton.grid(row=0, column=2)
5367

5468
surugayaCheck = tk.BooleanVar()
55-
surugayaCheckButton = tk.Checkbutton(window, text = "Suruga-ya", variable = surugayaCheck, onvalue = True, offvalue = False, height = 0, width = 0)
69+
surugayaCheckButton = tk.Checkbutton(
70+
window, text="Suruga-ya", variable=surugayaCheck, onvalue=True, offvalue=False, height=0, width=0)
5671
surugayaCheckButton.select()
57-
surugayaCheckButton.grid(row = 1, column = 0, sticky='w')
72+
surugayaCheckButton.grid(row=1, column=0, sticky='w')
5873

5974
mandarakeCheck = tk.BooleanVar()
60-
mandarakeCheckButton = tk.Checkbutton(window, text = "Mandarake", variable = mandarakeCheck, onvalue = True, offvalue = False, height = 0, width = 0)
75+
mandarakeCheckButton = tk.Checkbutton(
76+
window, text="Mandarake", variable=mandarakeCheck, onvalue=True, offvalue=False, height=0, width=0)
6177
mandarakeCheckButton.select()
62-
mandarakeCheckButton.grid(row = 1, column = 1)
78+
mandarakeCheckButton.grid(row=1, column=1)
6379

6480
mercariCheck = tk.BooleanVar()
65-
mercariCheckButton = tk.Checkbutton(window, text = "Mercari", variable = mercariCheck, onvalue = True, offvalue = False, height = 0, width = 0)
81+
mercariCheckButton = tk.Checkbutton(
82+
window, text="Mercari", variable=mercariCheck, onvalue=True, offvalue=False, height=0, width=0)
6683
mercariCheckButton.select()
67-
mercariCheckButton.grid(row = 2, column = 0, sticky='w')
84+
mercariCheckButton.grid(row=2, column=0, sticky='w')
6885

6986
yahooCheck = tk.BooleanVar()
70-
yahooCheckButton = tk.Checkbutton(window, text = "Yahoo Auction", variable = yahooCheck, onvalue = True, offvalue = False, height = 0, width = 0)
87+
yahooCheckButton = tk.Checkbutton(
88+
window, text="Yahoo Auction", variable=yahooCheck, onvalue=True, offvalue=False, height=0, width=0)
7189
yahooCheckButton.select()
72-
yahooCheckButton.grid(row = 2, column = 1)
90+
yahooCheckButton.grid(row=2, column=1)
7391

7492
otamartCheck = tk.BooleanVar()
75-
otamartCheckButton = tk.Checkbutton(window, text = "Otamart", variable = otamartCheck, onvalue = True, offvalue = False, height = 0, width = 0)
93+
otamartCheckButton = tk.Checkbutton(
94+
window, text="Otamart", variable=otamartCheck, onvalue=True, offvalue=False, height=0, width=0)
7695
otamartCheckButton.select()
77-
otamartCheckButton.grid(row = 3, column = 0, sticky='w')
78-
79-
window.mainloop()
80-
81-
82-
96+
otamartCheckButton.grid(row=2, column=2, sticky='w')
8397

98+
newestSort = tk.BooleanVar()
99+
newestSortButton = tk.Checkbutton(
100+
window, text="新品顺", variable=newestSort, onvalue=True, offvalue=False, height=0, width=0)
101+
newestSortButton.select()
102+
newestSortButton.grid(row=3, column=0, sticky='w')
84103

104+
window.mainloop()

0 commit comments

Comments
 (0)