-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
49 lines (46 loc) · 1.53 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import time
import modules.folderDelete as folderDelete
import modules.getItemName as getItemName
import modules.getPrice as getPrice
import modules.main_get_infomations as get_tirasi
import modules.tirasicut as tirasicut
from modules.path_and_do_areafunction import (get_file_path_do_area_function,
get_folder_path_do_area_function)
import OCR as OCR
try:
file = open(r"../web/static/csv/item.csv", "x")
except FileExistsError:
os.remove(r"../web/static/csv/item.csv")
file = open(r"../web/static/csv/item.csv", "x")
file.write("#店舗,商品,分類,価格\n")
print("チラシをダウンロード")
get_tirasi.get_resipe()
print("チラシのパスを取得")
pathList = get_folder_path_do_area_function("./dir_out")
for shopName, path in pathList:
print("チラシの切り抜き")
folderDelete.folderDelete("./cutimages")
tirasicut.tirasitm(path)
cutPathList = get_file_path_do_area_function("./cutimages")
print(cutPathList)
for cutPath in cutPathList:
print(cutPath)
ocrText = OCR.ocr_main(cutPath)
print(ocrText)
findPrice = getPrice.getGeminiAPIResponse(ocrText)
print(findPrice)
time.sleep(1)
itemName = getItemName.getGeminiAPIResponse(ocrText)
print(shopName, itemName)
file.write(
shopName.replace(" ", "")
+ ","
+ itemName
+ ","
+ "None"
+ ","
+ str(findPrice)
+ "\n"
)
file.close()