LoginSignup
3
5

More than 5 years have passed since last update.

curl -Iなpythonワンライナー

Posted at

人様のいにしえな環境でcurlなかったけど、pythonはあったので。

$ python -c "import urllib2;r=urllib2.urlopen('http://www.python.org');print r.info();"
Server: nginx
Content-Type: text/html; charset=utf-8
X-Frame-Options: SAMEORIGIN
X-Clacks-Overhead: GNU Terry Pratchett
Content-Length: 47424
Accept-Ranges: bytes
Date: Tue, 27 Sep 2016 11:07:15 GMT
Via: 1.1 varnish
Age: 2297
Connection: close
X-Served-By: cache-sin6921-SIN
X-Cache: HIT
X-Cache-Hits: 10
Vary: Cookie
Public-Key-Pins: hogehoge

$

参考:20.6. urllib2 — URL を開くための拡張可能なライブラリ — Python 2.7.x ドキュメント

もう少しいにしえだとこっちのがいいかも?

$ python -c "import httplib;conn = httplib.HTTPSConnection('www.python.org');conn.request('GET','/');r1 = conn.getresponse();print r1.status, r1.reason"
200 OK

$

参考:20.7. httplib — HTTP プロトコルクライアント — Python 2.7.x ドキュメント

pythonでワンライナーでhttpなの探すと大体以下なwebサーバ建てる方なので、そういやhttp getなワンライナーってないなと。

$ python -m SimpleHTTPServer 800

参考:20.19. SimpleHTTPServer — 簡潔な HTTP リクエストハンドラ — Python 2.7.x ドキュメント

そもそもperlのが入ってるか?なら以下っぽい。ま、モジュールあればだけど。

$ perl -MLWP::Simple -le'print get shift' http://www.dan.co.jp/

参考:一行野郎(one-liner)はperlにおまかせ

wget?知らない子ですね。

以上。

3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5