✅ 目標:GUI付きのセドリ管理ツール + Amazon連携
✅ 目標:GUI付きのセドリ管理ツール + Amazon連携
💡 機能要件(最初の段階)
-
GUIで商品登録
-
仕入れ価格・販売価格の入力
-
利益を自動計算して表示
-
Amazonから商品情報を取得して自動補完(ASINやキーワード検索)
🛠 技術スタック
分類 | 内容 |
---|---|
GUI | Tkinter (標準で使える、軽量)or PyQt5 (高機能・重い) |
Amazon連携 | Amazon Product Advertising API (公式API)またはスクレイピング |
データ保存 | とりあえずCSV で簡単に。あとからSQLite やpandas へ移行可能 |
📌 注意:Amazonのデータ取得方法について
方法 | 特徴 |
---|---|
✅ Amazon API(推奨) | 正規手段。検索や価格取得が安定。APIキー取得が必要(審査あり) |
❗ スクレイピング(代替案) | requests + BeautifulSoup で実装可能。が、利用規約違反のリスクあり。制限対策も必要 |
✅ ステップ1:GUIで商品を登録して利益計算する(Tkinter版)
import tkinter as tk
from tkinter import messagebox
from tkinter import ttk
class ProductManagerApp:
def __init__(self, root):
self.root = root
self.root.title("セドリ管理ツール")
# ラベルとエントリー
ttk.Label(root, text="商品名").grid(row=0, column=0)
self.name_entry = ttk.Entry(root, width=30)
self.name_entry.grid(row=0, column=1)
ttk.Label(root, text="仕入れ価格").grid(row=1, column=0)
self.cost_entry = ttk.Entry(root)
self.cost_entry.grid(row=1, column=1)
ttk.Label(root, text="販売価格").grid(row=2, column=0)
self.sale_entry = ttk.Entry(root)
self.sale_entry.grid(row=2, column=1)
# ボタン
self.calc_button = ttk.Button(root, text="利益計算", command=self.calculate_profit)
self.calc_button.grid(row=3, column=0, columnspan=2, pady=10)
# 結果表示
self.result_label = ttk.Label(root, text="")
self.result_label.grid(row=4, column=0, columnspan=2)
def calculate_profit(self):
try:
cost = float(self.cost_entry.get())
sale = float(self.sale_entry.get())
fee = sale * 0.1 # 手数料10%
profit = sale - cost - fee
self.result_label.config(text=f"利益: ¥{profit:.2f}")
except ValueError:
messagebox.showerror("入力エラー", "価格を正しく入力してください。")
# アプリ起動
if __name__ == "__main__":
root = tk.Tk()
app = ProductManagerApp(root)
root.mainloop()
✅ ステップ2:Amazon連携(API or スクレイピング)
▶ API連携の準備
-
APIキーとシークレットキーを取得
-
Python用ライブラリ:
bottlenose
,python-amazon-paapi
などが使用可能
▶ 例:キーワード検索で商品取得(API使用)
# pip install python-amazon-paapi
from amazon_paapi import AmazonApi
amazon = AmazonApi(
access_key="YOUR_ACCESS_KEY",
secret_key="YOUR_SECRET_KEY",
associate_tag="YOUR_TAG",
country="JP"
)
products = amazon.search_items(keywords="Nintendo Switch", search_index="All")
for item in products.items:
print(item.title, item.price)
👉 次に進むなら?
-
このGUIにAmazon API連携を組み込む
-
商品名入力 → Amazonで検索 → タイトル・価格を自動補完
-
CSV保存、在庫管理、LINE通知など拡張
コメント
コメントを投稿