MCPcopy Index your code
hub / github.com/hugapi/hug / top_post

Function top_post

examples/write_once.py:9–13  ·  view source on GitHub ↗

Returns the top post from the provided section

(section: hug.types.one_of(("news", "newest", "show")) = "news")

Source from the content-addressed store, hash-verified

7@hug.cli()
8@hug.get()
9def top_post(section: hug.types.one_of(("news", "newest", "show")) = "news"):
10 """Returns the top post from the provided section"""
11 content = requests.get("https://news.ycombinator.com/{0}".format(section)).content
12 text = content.decode("utf-8")
13 return text.split("<tr class='athing'>")[1].split("<a href")[1].split(">")[1].split("<")[0]

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected