pytrends-modern 0.2.3__tar.gz → 0.2.4__tar.gz
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.
- {pytrends_modern-0.2.3/pytrends_modern.egg-info → pytrends_modern-0.2.4}/PKG-INFO +1 -1
- pytrends_modern-0.2.4/examples/test_timeframes.py +55 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pyproject.toml +1 -1
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/__init__.py +1 -1
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/browser_config_camoufox.py +5 -1
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/request.py +13 -3
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/request_async.py +12 -1
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4/pytrends_modern.egg-info}/PKG-INFO +1 -1
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern.egg-info/SOURCES.txt +1 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/LICENSE +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/MANIFEST.in +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/README.md +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/examples/advanced_usage.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/examples/basic_usage.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/examples/example_browser_mode.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/examples/example_docker_usage.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/examples/test_async_integration.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/browser_config.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/camoufox_setup.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/cli.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/config.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/exceptions.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/proxy_extension.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/py.typed +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/rss.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/scraper.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern/utils.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern.egg-info/dependency_links.txt +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern.egg-info/entry_points.txt +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern.egg-info/requires.txt +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern.egg-info/top_level.txt +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/setup.cfg +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/tests/conftest.py +0 -0
- {pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/tests/test_basic.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytrends-modern
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Modern Google Trends API - Combining the best of pytrends, with RSS feeds, Selenium scraping, DrissionPage browser automation, and enhanced features
|
|
5
5
|
Author: pytrends-modern contributors
|
|
6
6
|
License: MIT
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Example: Using different timeframes with browser mode
|
|
4
|
+
|
|
5
|
+
Test both 'today 1-m' (default) and 'today 12-m' (past 12 months)
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from pytrends_modern import TrendReq, BrowserConfig
|
|
9
|
+
|
|
10
|
+
keyword = "Python"
|
|
11
|
+
|
|
12
|
+
print("=" * 70)
|
|
13
|
+
print("Testing Different Timeframes")
|
|
14
|
+
print("=" * 70)
|
|
15
|
+
|
|
16
|
+
# Test 1: Default timeframe (today 1-m)
|
|
17
|
+
print("\n📊 Test 1: Default timeframe (past month)")
|
|
18
|
+
config1 = BrowserConfig(
|
|
19
|
+
headless=False,
|
|
20
|
+
min_delay=2.0,
|
|
21
|
+
max_delay=4.0,
|
|
22
|
+
)
|
|
23
|
+
print(f"Timeframe: {config1.timeframe}")
|
|
24
|
+
|
|
25
|
+
pytrends1 = TrendReq(browser_config=config1)
|
|
26
|
+
pytrends1.kw_list = [keyword]
|
|
27
|
+
df1 = pytrends1.interest_over_time()
|
|
28
|
+
print(f"✓ Got {len(df1)} data points")
|
|
29
|
+
print(df1.head())
|
|
30
|
+
print(f"Date range: {df1.index.min()} to {df1.index.max()}")
|
|
31
|
+
|
|
32
|
+
# Close first browser before opening second
|
|
33
|
+
pytrends1._close_browser()
|
|
34
|
+
del pytrends1
|
|
35
|
+
|
|
36
|
+
# Test 2: Past 12 months
|
|
37
|
+
print("\n📊 Test 2: Past 12 months")
|
|
38
|
+
config2 = BrowserConfig(
|
|
39
|
+
headless=False,
|
|
40
|
+
min_delay=2.0,
|
|
41
|
+
max_delay=4.0,
|
|
42
|
+
timeframe='today 12-m'
|
|
43
|
+
)
|
|
44
|
+
print(f"Timeframe: {config2.timeframe}")
|
|
45
|
+
|
|
46
|
+
pytrends2 = TrendReq(browser_config=config2)
|
|
47
|
+
pytrends2.kw_list = [keyword]
|
|
48
|
+
df2 = pytrends2.interest_over_time()
|
|
49
|
+
print(f"✓ Got {len(df2)} data points")
|
|
50
|
+
print(df2.head())
|
|
51
|
+
print(f"Date range: {df2.index.min()} to {df2.index.max()}")
|
|
52
|
+
|
|
53
|
+
print("\n✅ Both timeframes working!")
|
|
54
|
+
print(f"\nPast month: {len(df1)} points")
|
|
55
|
+
print(f"Past 12 months: {len(df2)} points")
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pytrends-modern"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.4"
|
|
8
8
|
description = "Modern Google Trends API - Combining the best of pytrends, with RSS feeds, Selenium scraping, DrissionPage browser automation, and enhanced features"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -12,7 +12,6 @@ class BrowserConfig:
|
|
|
12
12
|
|
|
13
13
|
⚠️ LIMITATIONS:
|
|
14
14
|
- Only 1 keyword supported (no comparison)
|
|
15
|
-
- Only 'today 1-m' timeframe supported
|
|
16
15
|
- Only WORLDWIDE geo supported (no geo filtering)
|
|
17
16
|
- Requires Google account login (first run)
|
|
18
17
|
|
|
@@ -35,6 +34,9 @@ class BrowserConfig:
|
|
|
35
34
|
max_delay: Maximum delay between requests in seconds (default: 5)
|
|
36
35
|
persistent_context: Keep browser profile between sessions (default: True)
|
|
37
36
|
Set to False to use fresh profile each time (helps avoid 429)
|
|
37
|
+
timeframe: Time range for trends data (default: 'today 1-m')
|
|
38
|
+
- 'today 1-m': Past month
|
|
39
|
+
- 'today 12-m': Past 12 months
|
|
38
40
|
|
|
39
41
|
Example:
|
|
40
42
|
>>> from pytrends_modern import TrendReq, BrowserConfig
|
|
@@ -68,6 +70,7 @@ class BrowserConfig:
|
|
|
68
70
|
max_delay: float = 5.0,
|
|
69
71
|
persistent_context: bool = True,
|
|
70
72
|
custom_config: Optional[Dict[str, Any]] = None,
|
|
73
|
+
timeframe: str = 'today 1-m',
|
|
71
74
|
):
|
|
72
75
|
self.headless = headless
|
|
73
76
|
self.proxy_server = proxy_server
|
|
@@ -82,4 +85,5 @@ class BrowserConfig:
|
|
|
82
85
|
self.max_delay = max_delay
|
|
83
86
|
self.persistent_context = persistent_context
|
|
84
87
|
self.custom_config = custom_config or {}
|
|
88
|
+
self.timeframe = timeframe
|
|
85
89
|
|
|
@@ -92,7 +92,6 @@ class TrendReq:
|
|
|
92
92
|
|
|
93
93
|
⚠️ LIMITATIONS when using browser_config:
|
|
94
94
|
- Only 1 keyword supported (no comparison)
|
|
95
|
-
- Only 'today 1-m' timeframe supported
|
|
96
95
|
- Only WORLDWIDE geo supported (no geo filtering)
|
|
97
96
|
- Requires Chrome/Chromium browser installed
|
|
98
97
|
"""
|
|
@@ -109,7 +108,7 @@ class TrendReq:
|
|
|
109
108
|
warnings.warn(
|
|
110
109
|
"⚠️ Camoufox browser mode is EXPERIMENTAL and has limitations:\n"
|
|
111
110
|
" - Only 1 keyword supported (no keyword comparison)\n"
|
|
112
|
-
" -
|
|
111
|
+
" - Timeframe: 'today 1-m' (default) or 'today 12-m'\n"
|
|
113
112
|
" - Only WORLDWIDE geo supported\n"
|
|
114
113
|
" - Requires Google account login (first run)\n"
|
|
115
114
|
" - Login session is saved for future runs",
|
|
@@ -354,7 +353,18 @@ class TrendReq:
|
|
|
354
353
|
# Build URL
|
|
355
354
|
import urllib.parse
|
|
356
355
|
encoded_keyword = urllib.parse.quote(keyword)
|
|
357
|
-
|
|
356
|
+
|
|
357
|
+
# Get timeframe from config (default: 'today 1-m')
|
|
358
|
+
timeframe = getattr(self.browser_config, 'timeframe', 'today 1-m')
|
|
359
|
+
|
|
360
|
+
# Build URL with or without date parameter
|
|
361
|
+
if timeframe == 'today 12-m':
|
|
362
|
+
# Past 12 months - no date parameter needed
|
|
363
|
+
url = f"https://trends.google.com/trends/explore?q={encoded_keyword}&hl=en-GB"
|
|
364
|
+
else:
|
|
365
|
+
# Default: today 1-m or custom timeframe
|
|
366
|
+
encoded_timeframe = urllib.parse.quote(timeframe)
|
|
367
|
+
url = f"https://trends.google.com/trends/explore?date={encoded_timeframe}&q={encoded_keyword}&hl=en-GB"
|
|
358
368
|
|
|
359
369
|
try:
|
|
360
370
|
# Navigate and wait for network idle
|
|
@@ -216,7 +216,18 @@ class AsyncTrendReq:
|
|
|
216
216
|
# Build URL
|
|
217
217
|
import urllib.parse
|
|
218
218
|
encoded_keyword = urllib.parse.quote(keyword)
|
|
219
|
-
|
|
219
|
+
|
|
220
|
+
# Get timeframe from config (default: 'today 1-m')
|
|
221
|
+
timeframe = getattr(self.browser_config, 'timeframe', 'today 1-m')
|
|
222
|
+
|
|
223
|
+
# Build URL with or without date parameter
|
|
224
|
+
if timeframe == 'today 12-m':
|
|
225
|
+
# Past 12 months - no date parameter needed
|
|
226
|
+
url = f"https://trends.google.com/trends/explore?q={encoded_keyword}&hl=en-GB"
|
|
227
|
+
else:
|
|
228
|
+
# Default: today 1-m or custom timeframe
|
|
229
|
+
encoded_timeframe = urllib.parse.quote(timeframe)
|
|
230
|
+
url = f"https://trends.google.com/trends/explore?date={encoded_timeframe}&q={encoded_keyword}&hl=en-GB"
|
|
220
231
|
|
|
221
232
|
try:
|
|
222
233
|
# Navigate and wait for network idle
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytrends-modern
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Modern Google Trends API - Combining the best of pytrends, with RSS feeds, Selenium scraping, DrissionPage browser automation, and enhanced features
|
|
5
5
|
Author: pytrends-modern contributors
|
|
6
6
|
License: MIT
|
|
@@ -7,6 +7,7 @@ examples/basic_usage.py
|
|
|
7
7
|
examples/example_browser_mode.py
|
|
8
8
|
examples/example_docker_usage.py
|
|
9
9
|
examples/test_async_integration.py
|
|
10
|
+
examples/test_timeframes.py
|
|
10
11
|
pytrends_modern/__init__.py
|
|
11
12
|
pytrends_modern/browser_config.py
|
|
12
13
|
pytrends_modern/browser_config_camoufox.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytrends_modern-0.2.3 → pytrends_modern-0.2.4}/pytrends_modern.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|