Skip to content

AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary

refactor(linkedin): use http.get + scrapecreators_headers convention

Matt Van Horn545a8bdc335e
diff --git a/skills/last30days/scripts/lib/linkedin.py b/skills/last30days/scripts/lib/linkedin.py
index 07b28142..7eb04186 100644
--- a/skills/last30days/scripts/lib/linkedin.py
+++ b/skills/last30days/scripts/lib/linkedin.py
@@ -11,7 +11,6 @@ from __future__ import annotations
import re
from typing import Any, Dict, List
-from urllib.parse import urlencode
from . import http, log
@@ -56,15 +55,13 @@ def search_linkedin(
_log(f"Searching for '{topic}' (date_posted={date_posted})")
- params: dict[str, str] = {"query": topic, "date_posted": date_posted}
- url = f"{SC_BASE}/search/posts?{urlencode(params)}"
-
try:
- response = http.request(
- "GET",
- url,
- headers={"x-api-key": token},
+ response = http.get(
+ f"{SC_BASE}/search/posts",
+ params={"query": topic, "date_posted": date_posted},
+ headers=http.scrapecreators_headers(token),
timeout=30,
+ retries=2,
)
except http.HTTPError as exc:
_log(f"Search failed (HTTP {exc.status_code}): {exc}")
@@ -271,10 +268,13 @@ def search_profile(profile_url: str, token: str) -> Dict[str, Any]:
"""Fetch a LinkedIn profile (incl. `articles[]`) via ScrapeCreators."""
if not token or not profile_url:
return {}
- url = f"{SC_BASE}/profile?{urlencode({'url': profile_url})}"
try:
- response = http.request(
- "GET", url, headers={"x-api-key": token}, timeout=30
+ response = http.get(
+ f"{SC_BASE}/profile",
+ params={"url": profile_url},
+ headers=http.scrapecreators_headers(token),
+ timeout=30,
+ retries=2,
)
except http.HTTPError as exc:
_log(f"Profile fetch failed (HTTP {exc.status_code}): {exc}")
diff --git a/tests/test_linkedin.py b/tests/test_linkedin.py
index 33c8d7f7..dfd8853b 100644
--- a/tests/test_linkedin.py
+++ b/tests/test_linkedin.py
@@ -354,8 +354,8 @@ class TestEnrichArticles(unittest.TestCase):
# Bounded: exactly one profile call.
self.assertEqual(1, mock_request.call_count)
# And it fetched the matching author's profile, not the first author.
- called_url = mock_request.call_args[0][1]
- self.assertIn("mattvanhorn", called_url)
+ called_profile = mock_request.call_args.kwargs["params"]["url"]
+ self.assertIn("mattvanhorn", called_profile)
def test_keyword_topic_makes_no_profile_call(self):
with mock.patch("lib.linkedin.http.request") as mock_request: