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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

You can read my blog posts using curl

101 点作者 mdibaiee将近 3 年前

17 条评论

dxuh将近 3 年前
In these comments people have suggested to check for the User-Agent, but wouldn&#x27;t it make more sense to check if the Accept header mentions text&#x2F;html? I realize that curl sends &quot;Accept: <i>&#x2F;</i>&quot;, but if you wanted to see a page in plain text, you would have to pass -H &quot;Accept: text&#x2F;plain&quot;. I think that uses HTTP much more like it was intended.
评论 #32250079 未加载
评论 #32249720 未加载
评论 #32249440 未加载
评论 #32249378 未加载
bronikowski将近 3 年前
Two months ago I hacked something like that for my blog:<p><pre><code> curl https:&#x2F;&#x2F;fuse.pl&#x2F;beton&#x2F;10print.html # with code highlighting curl https:&#x2F;&#x2F;fuse.pl&#x2F;beton&#x2F;cegla.html # just prose</code></pre>
评论 #32251409 未加载
评论 #32249417 未加载
评论 #32249988 未加载
评论 #32250472 未加载
gotlou将近 3 年前
Wow, this is a nice feature! I&#x27;d much rather implement it by having a .txt or .raw file just in the same folder as the HTML page though, rather than having to go in the middle of the URL. I feel like it is more convenient to do so.<p>Example, rather than <a href="https:&#x2F;&#x2F;mahdi.blog&#x2F;raw&#x2F;raw-permalinks-for-accessibility&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mahdi.blog&#x2F;raw&#x2F;raw-permalinks-for-accessibility&#x2F;</a>, it would be <a href="https:&#x2F;&#x2F;mahdi.blog&#x2F;raw-permalinks-for-accessibility.raw" rel="nofollow">https:&#x2F;&#x2F;mahdi.blog&#x2F;raw-permalinks-for-accessibility.raw</a><p>It&#x27;s a minor nitpick really, but I quite like this idea! I think I&#x27;ll try to implement this for my website too.<p>As for the other people here wondering why User Agents weren&#x27;t used for this:<p>- Using static website hosting goes out the window, which is quite a shame because it makes everything so much easier<p>- User agents are pretty terrible for determining capabilities and intent (what if someone was using curl to get an actual webpage?)<p>- It will never cover all types of HTTP clients (a whitelist is pretty terrible as we have seen from various online services restricting Firefox users or Linux users from certain features for no other reason than their user agents weren&#x27;t in the list the developers used to check for the presence of certain features).
kevincox将近 3 年前
&gt; To make this easily readable on small screens and terminals, I used vim’s text-width setting to make sure my lines do not exceed 80 characters:<p>I never understand comments like these. Now if my terminal is 78 characters it is a mess or if it is 100 characters it is wasting space. If you just don&#x27;t wrap the lines my terminal does it at the right width.<p>Hard wrapping doesn&#x27;t work well. You need to know the target width to wrap and you don&#x27;t know that until someone actually opens the file. Every viewer I have ever tried is excellent at soft-wrapping. Let it do its thing.
评论 #32250023 未加载
评论 #32251617 未加载
评论 #32251383 未加载
eterps将近 3 年前
Or use:<p>lynx -dump &lt;regular URL&gt;<p>elinks -dump &lt;regular URL&gt;<p>(not the same thing of course, but it doesn&#x27;t require anything from the server other than reasonable HTML)
评论 #32251504 未加载
jpoesen将近 3 年前
Fun idea.<p>If the site is not a static one, you could check the request&#x27;s User Agent server-side, and return the raw version directly (or redirect to &#x2F;foo&#x2F;raw) if the UA contains &#x27;curl&#x27; or &#x27;wget&#x27;.<p>If the site is static and you are able &amp; willing to change your vhost config, you could detect the UA too, and redirect to &#x2F;foo&#x2F;raw.<p>Just a few ideas. This is a fun little project you&#x27;ve got here. Well done.
anderspitman将近 3 年前
You can read mine using netcat :P<p><a href="https:&#x2F;&#x2F;apitman.com&#x2F;19&#x2F;#netcatable" rel="nofollow">https:&#x2F;&#x2F;apitman.com&#x2F;19&#x2F;#netcatable</a>
pbronez将近 3 年前
Pretty cool. Short step from here to publish the blog via Gemini. That protocol uses Gemtext as the core hypertext, and it’s basically markdown.<p><a href="https:&#x2F;&#x2F;gemini.circumlunar.space&#x2F;software&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gemini.circumlunar.space&#x2F;software&#x2F;</a>
评论 #32250003 未加载
tgv将近 3 年前
Cute idea, but the first one I picked didn&#x27;t work very well: <a href="https:&#x2F;&#x2F;mahdi.blog&#x2F;raw&#x2F;mathematical-induction-proving-tiling-methods&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mahdi.blog&#x2F;raw&#x2F;mathematical-induction-proving-tiling...</a>
评论 #32249384 未加载
nstart将近 3 年前
If you know basic vim movements (j&#x2F;k for down&#x2F;up kind of basic stuff), you can pipe the output into less to read it in a more convenient way. Nothing major, just found it nicer to not have to scroll back up when the article loads<p>Example:<p>curl <a href="https:&#x2F;&#x2F;mahdi.blog&#x2F;raw&#x2F;self-hosted&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mahdi.blog&#x2F;raw&#x2F;self-hosted&#x2F;</a> | less
评论 #32250247 未加载
Sheeny96将近 3 年前
A cool add-on to this would be a plugin that automatically redirected &#x2F;latest to the latest blog post. That way, if the blogger were to publish say once a week every Tuesday, the user could alias the curl for maximum ease of use.
评论 #32249779 未加载
preisschild将近 3 年前
If you use glow[1] you can even format&#x2F;color the markdown nicely `<a href="https:&#x2F;&#x2F;mahdi.blog&#x2F;raw&#x2F;raw-permalinks-for-accessibility&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mahdi.blog&#x2F;raw&#x2F;raw-permalinks-for-accessibility&#x2F;</a> | glow -`<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;charmbracelet&#x2F;glow" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;charmbracelet&#x2F;glow</a>
webscout将近 3 年前
Also works with <a href="https:&#x2F;&#x2F;terminal.news" rel="nofollow">https:&#x2F;&#x2F;terminal.news</a>
评论 #32249790 未加载
Eriks将近 3 年前
Pipe output to mdless (or similar) and it will be readable even more
netsharc将近 3 年前
Why not use user agent detection (and maybe have a header&#x2F;footer that says &quot;This page has been formatted for readability based on your User Agent: curl&quot;).<p>I&#x27;m guessing the blog is made by a static site generator, so the above is harder than it seems. I suppose one could add a reverse proxy that redirects to &#x2F;raw&#x2F;$PAGE when it sees &quot;curl&quot;.
评论 #32249290 未加载
sylware将近 3 年前
this is brain unwashing: noscript&#x2F;basic (x)html browser compatibility.
评论 #32250661 未加载
cjvirtucio将近 3 年前
would&#x27;ve liked something like this on hugo
评论 #32250224 未加载