您现在的位置是:首页 > 文章详情

curl 作者开源 trurl,用于解析和操作 URL 的命令行工具

日期:2023-04-06点击:233

curl 作者 Daniel 宣布推出新的开源项目:trurl,这是一款用于解析和操作 URL 的命令行工具,主要是面向 shell 脚本作者提供。Daniel 称项目名字中的 'tr' 代表 translate 或 transpose。

Daniel 表示,URL 很难解析,因此导致软件存在许多安全问题。trurl 希望通过消除脚本和命令行作者到处重复发明轮子的需求来帮助缓解这个问题。

trurl 使用了 libcurl 的 URL 解析器,因此解析和理解 URL 的方式与命令行工具 curl 完全相同——使其成为完美的配套工具。

示例代码

  $ trurl --url https://curl.se --set host=example.com https://example.com/ $ trurl --set host=example.com --set scheme=ftp ftp://example.com/ $ trurl --url https://curl.se/we/are.html --redirect here.html https://curl.se/we/here.html $ trurl --url https://curl.se/we/../are.html --set port=8080 https://curl.se:8080/are.html $ trurl --url https://curl.se/we/are.html --get '{path}' /we/are.html $ trurl --url https://curl.se/we/are.html --get '{port}' 443 $ trurl https://example.com/hello.html --get '{scheme} {port} {path}' https 443 /hello.html $ trurl --url https://curl.se/hello --append path=you https://curl.se/hello/you $ trurl --url "https://curl.se?name=hello" --append query=search=string https://curl.se/?name=hello&search=string $ trurl --url-file url-list.txt --get '{host}' [one host name per URL in the input file] $ cat url-list.txt | trurl --url-file - --get '{host}' [one host name per URL in the input file] $ trurl "https://fake.host/hello#frag" --set user=::moo:: --json [ { "url": "https://%3a%3amoo%3a%3a@fake.host/hello#frag", "scheme": "https", "user": "::moo::", "host": "fake.host", "port": "443", "path": "/hello", "fragment": "frag" } ] $ trurl "https://example.com?search=hello&utm_source=tracker" --trim query="utm_*" https://example.com/?search=hello
原文链接:https://www.oschina.net/news/235599/introducing-trurl
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章