TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Better HN search with bash

1 点作者 ekns大约 10 年前
The interface for Algolia search is horrible for picking date ranges so I made this little bash function to fix it (noting that &quot;open&quot; is an alias to &quot;xdg-open&quot; for me on Linux).<p>Might work in other shells too.<p><pre><code> function hn() { if test $# -lt 1 || test $# -gt 3; then echo &quot;Usage: $0 &lt;query&gt; [start=1970] [end=now]&quot; echo &quot;start and end are ISO dates like 2014-03-23.&quot; return 1 fi query=$1 start=$(test $# -gt 1 &amp;&amp; date --date &quot;$2&quot; +%s || date --date @0 +%s) end=$(test $# -gt 2 &amp;&amp; date --date &quot;$3&quot; +%s || date +%s) url=&quot;https:&#x2F;&#x2F;hn.algolia.com&#x2F;?sort=byPopularity&amp;prefix=false&amp;page=0&amp;type=story&amp;query=${query}&amp;dateRange=custom&amp;dateStart=${start}&amp;dateEnd=${end}&quot; echo $url open &quot;$url&quot; }</code></pre>

1 comment

redox_大约 10 年前
Indeed, we never took the time to plug a date parser. Any chance you&#x27;ve time for a pull-request? <a href="https://github.com/algolia/hn-search/blob/master/app/assets/javascripts/controllers.js#L26" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;algolia&#x2F;hn-search&#x2F;blob&#x2F;master&#x2F;app&#x2F;assets&#x2F;...</a> and <a href="https://github.com/algolia/hn-search/blob/master/app/controllers/api/v1/base_controller.rb#L7" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;algolia&#x2F;hn-search&#x2F;blob&#x2F;master&#x2F;app&#x2F;control...</a> :)<p>That would be cool!