Dmitry Beresnev
commited on
Commit
·
7ca0d9b
1
Parent(s):
6be1c8b
fix container type, twitter news module
Browse files- .streamlit/config.toml +7 -0
- README.md +5 -4
- app/services/twitter_news_playwright.py +26 -1
.streamlit/config.toml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[server]
|
| 2 |
+
port = 7860
|
| 3 |
+
address = "0.0.0.0"
|
| 4 |
+
headless = true
|
| 5 |
+
|
| 6 |
+
[browser]
|
| 7 |
+
gatherUsageStats = false
|
README.md
CHANGED
|
@@ -3,12 +3,13 @@ title: FinancialPlatform
|
|
| 3 |
emoji: 📈
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
-
sdk:
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
| 11 |
-
python_version: 3.
|
| 12 |
short_description: Multi-asset analysis with OpenBB and AI insights
|
| 13 |
---
|
| 14 |
|
|
|
|
| 3 |
emoji: 📈
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
# sdk_version: 1.30.0
|
| 9 |
+
# app_file: app/app.py
|
| 10 |
pinned: false
|
| 11 |
license: apache-2.0
|
| 12 |
+
# python_version: 3.12
|
| 13 |
short_description: Multi-asset analysis with OpenBB and AI insights
|
| 14 |
---
|
| 15 |
|
app/services/twitter_news_playwright.py
CHANGED
|
@@ -183,6 +183,31 @@ class TwitterFinanceMonitor:
|
|
| 183 |
self.last_fetch = None
|
| 184 |
self.cache_ttl = 180 # 3 minutes
|
| 185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
def _scrape_twitter_profile(self, source_name: str, source_info: Dict, timeout: int = 15) -> List[Dict]:
|
| 187 |
"""Scrape tweets from a single Twitter profile using Playwright"""
|
| 188 |
if not PLAYWRIGHT_AVAILABLE:
|
|
@@ -193,7 +218,7 @@ class TwitterFinanceMonitor:
|
|
| 193 |
with sync_playwright() as p:
|
| 194 |
# Launch lightweight browser
|
| 195 |
browser = p.chromium.launch(
|
| 196 |
-
executable_path=
|
| 197 |
headless=True,
|
| 198 |
args=['--disable-blink-features=AutomationControlled']
|
| 199 |
)
|
|
|
|
| 183 |
self.last_fetch = None
|
| 184 |
self.cache_ttl = 180 # 3 minutes
|
| 185 |
|
| 186 |
+
# Find Chromium executable
|
| 187 |
+
self.chromium_path = self._find_chromium()
|
| 188 |
+
|
| 189 |
+
def _find_chromium(self) -> str:
|
| 190 |
+
"""Find Chromium installation path"""
|
| 191 |
+
import os
|
| 192 |
+
import shutil
|
| 193 |
+
|
| 194 |
+
# Try common paths
|
| 195 |
+
paths = [
|
| 196 |
+
'/usr/bin/chromium',
|
| 197 |
+
'/usr/bin/chromium-browser',
|
| 198 |
+
'/usr/lib/chromium/chromium',
|
| 199 |
+
shutil.which('chromium'),
|
| 200 |
+
shutil.which('chromium-browser'),
|
| 201 |
+
]
|
| 202 |
+
|
| 203 |
+
for path in paths:
|
| 204 |
+
if path and os.path.exists(path):
|
| 205 |
+
logger.info(f"Found Chromium at: {path}")
|
| 206 |
+
return path
|
| 207 |
+
|
| 208 |
+
logger.warning("Chromium not found in standard paths")
|
| 209 |
+
return '/usr/bin/chromium' # Fallback
|
| 210 |
+
|
| 211 |
def _scrape_twitter_profile(self, source_name: str, source_info: Dict, timeout: int = 15) -> List[Dict]:
|
| 212 |
"""Scrape tweets from a single Twitter profile using Playwright"""
|
| 213 |
if not PLAYWRIGHT_AVAILABLE:
|
|
|
|
| 218 |
with sync_playwright() as p:
|
| 219 |
# Launch lightweight browser
|
| 220 |
browser = p.chromium.launch(
|
| 221 |
+
executable_path=self.chromium_path,
|
| 222 |
headless=True,
|
| 223 |
args=['--disable-blink-features=AutomationControlled']
|
| 224 |
)
|