Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
import requests
|
3 |
import json
|
4 |
import os
|
@@ -6,12 +6,29 @@ from datetime import datetime, timedelta
|
|
6 |
|
7 |
API_KEY = os.getenv("SERPHOUSE_API_KEY")
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
"
|
12 |
-
"
|
13 |
-
"
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
def search_serphouse(query, country, page=1, num_result=100):
|
17 |
url = "https://api.serphouse.com/serp/live"
|
@@ -23,8 +40,8 @@ def search_serphouse(query, country, page=1, num_result=100):
|
|
23 |
payload = {
|
24 |
"data": {
|
25 |
"q": query,
|
26 |
-
"domain": "google.com",
|
27 |
-
"
|
28 |
"lang": "en",
|
29 |
"device": "desktop",
|
30 |
"serp_type": "news",
|
|
|
1 |
+
iimport gradio as gr
|
2 |
import requests
|
3 |
import json
|
4 |
import os
|
|
|
6 |
|
7 |
API_KEY = os.getenv("SERPHOUSE_API_KEY")
|
8 |
|
9 |
+
# 국가와 country_code 매핑
|
10 |
+
COUNTRY_CODES = {
|
11 |
+
"United States": "US",
|
12 |
+
"United Kingdom": "GB",
|
13 |
+
"Canada": "CA",
|
14 |
+
"Australia": "AU",
|
15 |
+
"Germany": "DE",
|
16 |
+
"France": "FR",
|
17 |
+
"Japan": "JP",
|
18 |
+
"South Korea": "KR",
|
19 |
+
"China": "CN",
|
20 |
+
"India": "IN",
|
21 |
+
"Brazil": "BR",
|
22 |
+
"Mexico": "MX",
|
23 |
+
"Russia": "RU",
|
24 |
+
"Italy": "IT",
|
25 |
+
"Spain": "ES",
|
26 |
+
"Netherlands": "NL",
|
27 |
+
"Singapore": "SG",
|
28 |
+
"Hong Kong": "HK"
|
29 |
+
}
|
30 |
+
|
31 |
+
MAJOR_COUNTRIES = list(COUNTRY_CODES.keys())
|
32 |
|
33 |
def search_serphouse(query, country, page=1, num_result=100):
|
34 |
url = "https://api.serphouse.com/serp/live"
|
|
|
40 |
payload = {
|
41 |
"data": {
|
42 |
"q": query,
|
43 |
+
"domain": "google.com",
|
44 |
+
"country_code": COUNTRY_CODES.get(country, "US"), # country_code 사용
|
45 |
"lang": "en",
|
46 |
"device": "desktop",
|
47 |
"serp_type": "news",
|