Skip to content

Commit 5b426ee

Browse files
authored
Add open graph scrape (#105)
Add og call support
1 parent cd45832 commit 5b426ee

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

stream/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,12 @@ def create_redirect_url(self, target_url, user_id, events):
455455
# validate the target url is valid
456456
Request("GET", target_url).prepare()
457457
return prepared_request.url
458+
459+
def og(self, target_url):
460+
"""
461+
Retrieve open graph information from a URL which you can
462+
then use to add images and a description to activities.
463+
"""
464+
auth_token = self.create_jwt_token("*", "*", feed_id="*")
465+
params = {"url": target_url}
466+
return self.get("og/", auth_token, params=params)

stream/tests/test_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,3 +1480,8 @@ def test_feed_enrichment_reaction_counts(self):
14801480
reaction.pop("duration")
14811481
enriched_response = f.get(reactions={"counts": True})
14821482
self.assertEqual(enriched_response["results"][0]["reaction_counts"]["like"], 1)
1483+
1484+
def test_og(self):
1485+
response = client.og("https://google.com")
1486+
self.assertTrue("title" in response)
1487+
self.assertTrue("description" in response)

0 commit comments

Comments
 (0)