I’ve tried using pythorhead
search_results = lemmy.search(post_url)
but I get
AttributeError: 'Lemmy' object has no attribute 'search'
I’ve also tried requesting it myself but I don’t get any results from the API even when I get it when searching for the same URL from the web interface.
@backoff.on_exception(
backoff.expo,
requests.exceptions.RequestException,
max_time=MAX_BACKOFF_TIME,
)
def search(instance: str, url: str) -> Dict[str, Any]:
api = f"https://{instance}/api/v3/search"
query = f"?q={url}"
response = requests.get(api + query)
if response.status_code == 200:
res: Dict[str, Any] = response.json()
return res
else:
return {}
This makes it look more difficult than what I expected. https://programming.dev/comment/50809
You must log in or register to comment.