Spaces:
Sleeping
Sleeping
Update tools/social_media_search.py
Browse files
tools/social_media_search.py
CHANGED
|
@@ -22,13 +22,14 @@ class SocialMediaSearchTool:
|
|
| 22 |
def forward(self, name: str, platform: str) -> Dict:
|
| 23 |
query = f"{name} {platform}"
|
| 24 |
results = self.ddgs.text(query, max_results=5)
|
| 25 |
-
|
| 26 |
for result in results:
|
| 27 |
if re.search(self.platforms[platform], result["href"]):
|
|
|
|
| 28 |
return {
|
| 29 |
"platform": platform,
|
| 30 |
"url": result["href"],
|
| 31 |
"title": result["title"],
|
| 32 |
"description": result["body"]
|
| 33 |
}
|
| 34 |
-
return
|
|
|
|
| 22 |
def forward(self, name: str, platform: str) -> Dict:
|
| 23 |
query = f"{name} {platform}"
|
| 24 |
results = self.ddgs.text(query, max_results=5)
|
| 25 |
+
postprocessed_results = []
|
| 26 |
for result in results:
|
| 27 |
if re.search(self.platforms[platform], result["href"]):
|
| 28 |
+
postprocessed_results += [f"(platform: {platform})\n[{result['title']}]({result['href']})\n{result['body']}" for result in results]
|
| 29 |
return {
|
| 30 |
"platform": platform,
|
| 31 |
"url": result["href"],
|
| 32 |
"title": result["title"],
|
| 33 |
"description": result["body"]
|
| 34 |
}
|
| 35 |
+
return "platform "+platform+" error:"+" No profile found"
|