5 ms·
Ask HN: Is there any way to rank stories on HN from sites based on votes?
(Excuse my noobness, please.)
Hi, I think you already know that when you click on the post link of a story, all stories from that top level domain appears.
If there is a video from YouTube, then, if I click on
(youtube.com)
, then all posts having YouTube as a top level domain appears as result.
The API call looks like
from?site=YouTube.com
But this is always sorted based on time of posting. Can this be changed?
Say, I want to see all stories from New Yorker, ranked based on votes those stories received, what do I do?
I know this part-
https://news.ycombinator.com/from?site=newyorker.com
But what more do I add to rank the result based on number of votes?
Or is there a completely different way to do this?
- perihelions 5y agoYou can use the built-in Algolia search, like so: https://hn.algolia.com/?query=newyorker.com&type=story&sort=byPopularity https://hn.algolia.com/?query=newyorker.com&type=story&sort=... With the domain as the search string ("&query=newyorker.com"), the results will be returned in groups, in (to my understanding) this order: - (0) Posts with the literal string "newyorker.com" in the *title* (there are currently none) - (1) Text posts containing "newyorker.com" links - (2) Posts from the domain newyorker.com (or a URL that contains that substring) If you scroll down to the (2) section, you will find what you asked for: all newyorker.com submissions, sorted by popularity.
- rg111 5y agoThanks a bunch for this. This somewhat works. This is not an ideal solution as the length of the first "section" will be variable as they depend on how many people chose to write URLs on their posts that contain the site string. If I cannot find a better solution, I will live with this. I will randomly pick up a page and click on that- if all the results are text posts on HN, I will go further right. If they appear to be links, then I will go left until I find the first one- like a sorting algorithm. Thanks, anyway.
- gabrielsroka 5y agoCheck the API docs https://hn.algolia.com/api https://hn.algolia.com/api for restrictSearchableAttributes=url So maybe https://hn.algolia.com/api/v1/search?query=newyorker.com/&restrictSearchableAttributes=url https://hn.algolia.com/api/v1/search?query=newyorker.com/&re... See also my two posts here https://news.ycombinator.com/item?id=30331893 https://news.ycombinator.com/item?id=30331893
- rg111 5y agorestrictSearchableAttributes=url did not work without the API search. The links in text stories are also recognised as url, and that is reflected here. https://hn.algolia.com/?q=newyorker.com&restrictSearchableAttributes=url Was my query and it made no external difference. But when I tried directly accessing the API, it worked and threw me a JSON.
- gabrielsroka 5y agoCorrect. I'm talking about using the API, and I included a link to some client code and also a bookmarklet.
- rg111 5y agoAlgolia limits search results to 100 pages. The youtube.com results started at 99. So the list was cut very short.
- gabrielsroka 5y agoHow about this? https://jsfiddle.net/mbs1u5vp/ https://jsfiddle.net/mbs1u5vp/
- rg111 5y agoCool. But the results are still cut short. The last result had 785 point. Surely there are hundreds below it. Any way to get them?
- gabrielsroka 5y agoClick the button at the bottom called Next.
- rg111 5y agoThe button doesn't appear on mobile web. Does fine on desktop which I just checked. Thanks!
- gabrielsroka 5y agoIt works for me on Chrome for Android. You just have to scroll down all the way.
- rg111 5y agoI am using Bromite on Android. The Next still doesn't appear. Many thanks for writing it, though.
- gabrielsroka 5y ago