google-news-trends-mcp 0.1.2__py3-none-any.whl → 0.1.3__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
@@ -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.3
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=TH8y4lHHyjGRJ_CGHsiU425sQuFEefR_cg27br9fKr8,12014
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.3.dist-info/licenses/LICENSE,sha256=5dsv2ZI5EZIer0a9MktVmILVrlp5vqH_0tPIe3bRLgE,1067
7
+ google_news_trends_mcp-0.1.3.dist-info/METADATA,sha256=5ixq1RxbZOw6R4KWbpOd14Qp3zQVJ815hP_yCf9rl-s,4580
8
+ google_news_trends_mcp-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ google_news_trends_mcp-0.1.3.dist-info/entry_points.txt,sha256=eVT3xd6YJQgsWAUBwhnffuwhXNF7yyt_uco6fjBy-1o,130
10
+ google_news_trends_mcp-0.1.3.dist-info/top_level.txt,sha256=RFheDbzhNnEV_Y3iFNm7jhRhY1P1wQgfiYqVpXCTD_U,23
11
+ google_news_trends_mcp-0.1.3.dist-info/RECORD,,