Update app.py
Browse files
app.py
CHANGED
@@ -115,25 +115,29 @@ def get_search_volumes(keyword):
|
|
115 |
try:
|
116 |
data = api.get_keywords_data([keyword])
|
117 |
if 'keywordList' in data and len(data['keywordList']) > 0:
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
137 |
else:
|
138 |
return (keyword, 0, 0, 0)
|
139 |
except Exception as e:
|
@@ -219,10 +223,10 @@ def get_monthly_search_volumes(keywords, include_related_keywords=True):
|
|
219 |
for future in blog_futures:
|
220 |
try:
|
221 |
keyword, blog_count = future.result()
|
222 |
-
temp_results.append((keyword, 0, 0, 0, blog_count))
|
223 |
except Exception as e:
|
224 |
print(f"Error fetching blog count for keyword '{keyword}': {e}")
|
225 |
-
temp_results.append((keyword, 0, 0, 0, "Error"))
|
226 |
results = temp_results
|
227 |
|
228 |
return results
|
|
|
115 |
try:
|
116 |
data = api.get_keywords_data([keyword])
|
117 |
if 'keywordList' in data and len(data['keywordList']) > 0:
|
118 |
+
# keywordList์์ ์
๋ ฅํ ํค์๋์ ์ผ์นํ๋ ํญ๋ชฉ์ ์ฐพ์ต๋๋ค.
|
119 |
+
for item in data['keywordList']:
|
120 |
+
if item['relKeyword'].strip().lower() == keyword.strip().lower():
|
121 |
+
monthly_pc = item.get('monthlyPcQcCnt', 0)
|
122 |
+
monthly_mobile = item.get('monthlyMobileQcCnt', 0)
|
123 |
+
|
124 |
+
if isinstance(monthly_pc, str):
|
125 |
+
monthly_pc = monthly_pc.replace(',', '').replace('< 10', '0')
|
126 |
+
try:
|
127 |
+
monthly_pc = int(monthly_pc)
|
128 |
+
except ValueError:
|
129 |
+
monthly_pc = 0
|
130 |
+
if isinstance(monthly_mobile, str):
|
131 |
+
monthly_mobile = monthly_mobile.replace(',', '').replace('< 10', '0')
|
132 |
+
try:
|
133 |
+
monthly_mobile = int(monthly_mobile)
|
134 |
+
except ValueError:
|
135 |
+
monthly_mobile = 0
|
136 |
+
|
137 |
+
total_searches = monthly_pc + monthly_mobile
|
138 |
+
return (keyword, monthly_pc, monthly_mobile, total_searches)
|
139 |
+
# ์
๋ ฅํ ํค์๋์ ์ผ์นํ๋ ํญ๋ชฉ์ด ์์ ๊ฒฝ์ฐ
|
140 |
+
return (keyword, 0, 0, 0)
|
141 |
else:
|
142 |
return (keyword, 0, 0, 0)
|
143 |
except Exception as e:
|
|
|
223 |
for future in blog_futures:
|
224 |
try:
|
225 |
keyword, blog_count = future.result()
|
226 |
+
temp_results.append((keyword, results[0][1], results[0][2], results[0][3], blog_count))
|
227 |
except Exception as e:
|
228 |
print(f"Error fetching blog count for keyword '{keyword}': {e}")
|
229 |
+
temp_results.append((keyword, results[0][1], results[0][2], results[0][3], "Error"))
|
230 |
results = temp_results
|
231 |
|
232 |
return results
|