Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -6,30 +6,28 @@ from datetime import datetime, timedelta
|
|
6 |
|
7 |
API_KEY = os.getenv("SERPHOUSE_API_KEY")
|
8 |
|
9 |
-
#
|
10 |
-
|
11 |
-
"United States": "
|
12 |
-
"United Kingdom": "
|
13 |
-
"Canada": "
|
14 |
-
"Australia": "
|
15 |
-
"Germany": "
|
16 |
-
"France": "
|
17 |
-
"Japan": "
|
18 |
-
"South Korea": "
|
19 |
-
"China": "
|
20 |
-
"India": "
|
21 |
-
"Brazil": "
|
22 |
-
"Mexico": "
|
23 |
-
"Russia": "
|
24 |
-
"Italy": "
|
25 |
-
"Spain": "
|
26 |
-
"Netherlands": "
|
27 |
-
"Singapore": "
|
28 |
-
"Hong Kong": "
|
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"
|
35 |
|
@@ -41,7 +39,7 @@ def search_serphouse(query, country, page=1, num_result=100):
|
|
41 |
"data": {
|
42 |
"q": query,
|
43 |
"domain": "google.com",
|
44 |
-
"
|
45 |
"lang": "en",
|
46 |
"device": "desktop",
|
47 |
"serp_type": "news",
|
|
|
6 |
|
7 |
API_KEY = os.getenv("SERPHOUSE_API_KEY")
|
8 |
|
9 |
+
# COUNTRY_CODES를 다음과 같이 loc_id로 변경
|
10 |
+
COUNTRY_LOCATIONS = {
|
11 |
+
"United States": "1026201", # Alba,Texas,United States
|
12 |
+
"United Kingdom": "2635167", # Birmingham,England,United Kingdom
|
13 |
+
"Canada": "5907364", # Burnaby,British Columbia,Canada
|
14 |
+
"Australia": "2147714", # Sydney,New South Wales,Australia
|
15 |
+
"Germany": "2950159", # Berlin,Berlin,Germany
|
16 |
+
"France": "2988507", # Paris,Île-de-France,France
|
17 |
+
"Japan": "1850147", # Tokyo,Tokyo,Japan
|
18 |
+
"South Korea": "1835848", # Seoul,Seoul,South Korea
|
19 |
+
"China": "1816670", # Beijing,Beijing,China
|
20 |
+
"India": "1261481", # New Delhi,Delhi,India
|
21 |
+
"Brazil": "3448439", # São Paulo,São Paulo,Brazil
|
22 |
+
"Mexico": "3530597", # Mexico City,Mexico City,Mexico
|
23 |
+
"Russia": "524901", # Moscow,Moscow,Russia
|
24 |
+
"Italy": "3169070", # Rome,Lazio,Italy
|
25 |
+
"Spain": "3117735", # Madrid,Madrid,Spain
|
26 |
+
"Netherlands": "2759794", # Amsterdam,North Holland,Netherlands
|
27 |
+
"Singapore": "1880252", # Singapore,Central Singapore,Singapore
|
28 |
+
"Hong Kong": "1819729" # Hong Kong,Central and Western District,Hong Kong
|
29 |
}
|
30 |
|
|
|
|
|
31 |
def search_serphouse(query, country, page=1, num_result=100):
|
32 |
url = "https://api.serphouse.com/serp/live"
|
33 |
|
|
|
39 |
"data": {
|
40 |
"q": query,
|
41 |
"domain": "google.com",
|
42 |
+
"loc_id": COUNTRY_LOCATIONS.get(country, "1026201"), # loc_id 사용
|
43 |
"lang": "en",
|
44 |
"device": "desktop",
|
45 |
"serp_type": "news",
|