google-news-trends-mcp 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,10 +24,8 @@ from contextlib import asynccontextmanager
24
24
  tr = Trends()
25
25
 
26
26
  scraper = cloudscraper.create_scraper(
27
- # Challenge handling
28
27
  interpreter="js2py", # Best compatibility for v3 challenges
29
28
  delay=5, # Extra time for complex challenges
30
- # Stealth mode
31
29
  # enable_stealth=True,
32
30
  # stealth_options={
33
31
  # 'min_delay': 2.0,
@@ -36,15 +34,13 @@ scraper = cloudscraper.create_scraper(
36
34
  # 'randomize_headers': True,
37
35
  # 'browser_quirks': True
38
36
  # },
39
- # Browser emulation
40
37
  browser="chrome",
41
- # Debug mode
42
38
  debug=False,
43
39
  )
44
40
 
45
41
  google_news = GNews(
46
42
  language="en",
47
- exclude_websites=["mensjournal.com"],
43
+ # exclude_websites=[],
48
44
  )
49
45
 
50
46
  playwright = None
@@ -66,7 +62,6 @@ def shutdown_browser():
66
62
 
67
63
 
68
64
  async def get_browser() -> Browser:
69
- global browser
70
65
  if browser is None:
71
66
  await startup_browser()
72
67
  return browser
@@ -88,12 +83,10 @@ async def download_article_with_playwright(url) -> newspaper.Article | None:
88
83
  """
89
84
  try:
90
85
  async with browser_context() as context:
91
- # context = await new_context()
92
86
  page = await context.new_page()
93
87
  await page.goto(url, wait_until="domcontentloaded")
94
88
  await asyncio.sleep(2) # Wait for the page to load completely
95
89
  content = await page.content()
96
- # await context.close()
97
90
  article = newspaper.article(url, input_html=content, language="en")
98
91
  return article
99
92
  except Exception as e:
@@ -133,15 +126,13 @@ async def download_article(url: str, nlp: bool = True) -> newspaper.Article | No
133
126
  print(f"Error downloading article with cloudscraper from {url}\n {e.args}")
134
127
 
135
128
  try:
136
- if article is None:
129
+ if article is None or not article.text:
137
130
  # If newspaper failed, try downloading with Playwright
138
131
  print(f"Retrying with Playwright for {url}")
139
132
  article = await download_article_with_playwright(url)
140
133
  article.parse()
141
134
  if nlp:
142
135
  article.nlp()
143
- if article.publish_date:
144
- article.publish_date = article.publish_date.isoformat()
145
136
  except Exception as e:
146
137
  print(f"Error parsing article from {url}\n {e.args}")
147
138
  return None
@@ -173,8 +164,6 @@ async def get_news_by_keyword(
173
164
  period: is the number of days to look back for articles.
174
165
  max_results: is the maximum number of results to return.
175
166
  nlp: If True, will perform NLP on the articles to extract keywords and summary.
176
- Returns:
177
- list[newspaper.Article]: A list of newspaper.Article objects containing the articles.
178
167
  """
179
168
  google_news.period = f"{period}d"
180
169
  google_news.max_results = max_results
@@ -193,8 +182,6 @@ async def get_top_news(
193
182
  period: is the number of days to look back for top articles.
194
183
  max_results: is the maximum number of results to return.
195
184
  nlp: If True, will perform NLP on the articles to extract keywords and summary.
196
- Returns:
197
- list[newspaper.Article]: A list of newspaper.Article objects containing the top news articles.
198
185
  """
199
186
  google_news.period = f"{period}d"
200
187
  google_news.max_results = max_results
@@ -213,8 +200,6 @@ async def get_news_by_location(
213
200
  period: is the number of days to look back for articles.
214
201
  max_results: is the maximum number of results to return.
215
202
  nlp: If True, will perform NLP on the articles to extract keywords and summary.
216
- Returns:
217
- list[newspaper.Article]: A list of newspaper.Article objects containing the articles for the specified location
218
203
  """
219
204
  google_news.period = f"{period}d"
220
205
  google_news.max_results = max_results
@@ -241,8 +226,6 @@ async def get_news_by_topic(
241
226
  period: is the number of days to look back for articles.
242
227
  max_results: is the maximum number of results to return.
243
228
  nlp: If True, will perform NLP on the articles to extract keywords and summary.
244
- Returns:
245
- list[newspaper.Article]: A list of newspaper.Article objects containing the articles for the specified topic
246
229
  """
247
230
  google_news.period = f"{period}d"
248
231
  google_news.max_results = max_results
@@ -262,9 +245,6 @@ async def get_trending_terms(
262
245
  geo: is the country code, e.g. 'US', 'GB', 'IN', etc.
263
246
  full_data: if True, returns full data for each trend, otherwise returns only the trend and volume.
264
247
  max_results: is the maximum number of results to return, default is 100.
265
- Returns:
266
- list[tuple[str, int]]: A list of tuples containing the trend keyword and its volume.
267
- If full_data is True, each tuple will also contain additional data such as related queries and trend type.
268
248
  """
269
249
  try:
270
250
  trends = list(tr.trending_now(geo=geo))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-news-trends-mcp
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: An MCP server to access Google News and Google Trends.
5
5
  Author-email: Jesse Manek <jesse.manek@gmail.com>
6
6
  License-Expression: MIT
@@ -37,7 +37,7 @@ The returned data currently uses a lot of tokens, so it is recommended to always
37
37
  - Search Google News articles based on keyword, location, topic
38
38
  - Get top news stories from Google News
39
39
  - Google Trends keywords base on location
40
- - Optional NLP processing to summarize articles and extract keywords
40
+ - Optional NLP to summarize articles and extract keywords
41
41
 
42
42
  ## Installation
43
43
 
@@ -1,11 +1,11 @@
1
1
  google_news_trends_mcp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  google_news_trends_mcp/__main__.py,sha256=ysiAk_xpnnW3lrLlzdIQQa71tuGBRT8WocbecBsY2Fs,87
3
3
  google_news_trends_mcp/cli.py,sha256=fi0qocr-nc3UbGKOR5GLrmfsEjhU_M6ZJ7UAyLoC8ds,4012
4
- google_news_trends_mcp/news.py,sha256=o3lNRx_lt1h2ojHW0pXhfQhs8n35pnvgeV6-iTi_1RA,12294
4
+ google_news_trends_mcp/news.py,sha256=UF1r5vcew2QKGJH1K6wy5_xlmRBsKLyqrhObbNz3C8Y,11307
5
5
  google_news_trends_mcp/server.py,sha256=qwQ_9UKnOLybUGCmUH4sJWxKsmJHZCg7PKimFXgr58c,9468
6
- google_news_trends_mcp-0.1.2.dist-info/licenses/LICENSE,sha256=5dsv2ZI5EZIer0a9MktVmILVrlp5vqH_0tPIe3bRLgE,1067
7
- google_news_trends_mcp-0.1.2.dist-info/METADATA,sha256=dFijMlwb30QPODje_SYh-upF__QXNnxy6v7jDyq_O2c,4591
8
- google_news_trends_mcp-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- google_news_trends_mcp-0.1.2.dist-info/entry_points.txt,sha256=eVT3xd6YJQgsWAUBwhnffuwhXNF7yyt_uco6fjBy-1o,130
10
- google_news_trends_mcp-0.1.2.dist-info/top_level.txt,sha256=RFheDbzhNnEV_Y3iFNm7jhRhY1P1wQgfiYqVpXCTD_U,23
11
- google_news_trends_mcp-0.1.2.dist-info/RECORD,,
6
+ google_news_trends_mcp-0.1.4.dist-info/licenses/LICENSE,sha256=5dsv2ZI5EZIer0a9MktVmILVrlp5vqH_0tPIe3bRLgE,1067
7
+ google_news_trends_mcp-0.1.4.dist-info/METADATA,sha256=yJ9SrQxh94LAK9Mvh5IQ2daSlFWpYH-ZdLdY1ZF3kOk,4580
8
+ google_news_trends_mcp-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ google_news_trends_mcp-0.1.4.dist-info/entry_points.txt,sha256=eVT3xd6YJQgsWAUBwhnffuwhXNF7yyt_uco6fjBy-1o,130
10
+ google_news_trends_mcp-0.1.4.dist-info/top_level.txt,sha256=RFheDbzhNnEV_Y3iFNm7jhRhY1P1wQgfiYqVpXCTD_U,23
11
+ google_news_trends_mcp-0.1.4.dist-info/RECORD,,