seawolf2357 commited on
Commit
5fdee54
·
verified ·
1 Parent(s): 81bf281

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -23
app.py CHANGED
@@ -6,30 +6,28 @@ from datetime import datetime, timedelta
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"
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
- "country_code": COUNTRY_CODES.get(country, "US"), # country_code 사용
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",