this post was submitted on 19 Jul 2023
29 points (96.8% liked)

Python

6288 readers
3 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

๐Ÿ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

๐Ÿ Python project:
๐Ÿ’“ Python Community:
โœจ Python Ecosystem:
๐ŸŒŒ Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
 

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 are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] -1 points 1 year ago

"Searching" is forbidden since it is questioning the official story of a government, please try this instead: https://old.reddit.com/r/China/comments/wgoz19/andy_boreham_after_many_predictions_that_aged/