How to get the contents of a webpage in a shell variable?

后端 未结 6 1444
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 08:13

In Linux how can I fetch an URL and get its contents in a variable in shell script?

6条回答
  •  清歌不尽
    2020-12-07 08:43

    You can use curl or wget to retrieve the raw data, or you can use w3m -dump to have a nice text representation of a web page.

    $ foo=$(w3m -dump http://www.example.com/); echo $foo
    You have reached this web page by typing "example.com", "example.net","example.org" or "example.edu" into your web browser. These domain names are reserved for use in documentation and are not available for registration. See RFC 2606, Section 3.
    

提交回复
热议问题