Linux下curl和netcat的使用方法有哪些?

摘要:CURL 语法: curl [option] [url] 常用参数:-A--user-agent <string> 设置用户代理发送给服务器-b--cookie <nam
CURL 语法: curl [option] [url] 常用参数: -A/--user-agent <string> 设置用户代理发送给服务器 -b/--cookie <name=string/file> cookie字符串或文件读取位置 -c/--cookie-jar <file> 操作结束后把cookie写入到这个文件中 -C/--continue-at <offset> 断点续转 -D/--dump-header <file> 把header信息写入到该文件中 -e/--referer 来源网址 -f/--fail 连接失败时不显示http错误 -o/--output 把输出写到该文件中 -O/--remote-name 把输出写到该文件中,保留远程文件的文件名 -r/--range <range> 检索来自HTTP/1.1或FTP服务器字节范围 -s/--silent 静音模式。不输出任何东西 -T/--upload-file <file> 上传文件 -u/--user <user[:password]> 设置服务器的用户和密码 -w/--write-out [format] 什么输出完成后 -x/--proxy <host[:port]> 在给定的端口上使用HTTP代理 -#/--progress-bar 进度条显示当前的传送状态 例子: 1.1、访问网址,打印响应的内容(html代码) curl http://www.test.com 1.2、参数-f显示抓取错误, curl -f http://www.test.com/error 1.3、保存访问的文件 curl http://www.test.com >> test.html 1.4、可以使用curl的内置option:-o(小写)保存网页 curl -o test.html http://www.test. 1.5、参数-O(大写)保存网页中的文件,注意url要具体到某个文件,不然抓不下来,比如http://www.test.com/page/2/ 是无法抓取的 curl -O http://www.test.com/hello.xml 1.6、测试网页返回值,在脚本中,这是很常见的测试网站是否正常的用法,一般返回200 curl -o /dev/null -s -w %{http_code} www.test.com 1.7、指定proxy服务器以及其端口,参数 -x 用来支持设置代理 curl -x 192.168.100.100:1080 http://www.test.com 1.8、选项-u完成HTTP或FTP认证 curl -u username:password http://www.test.com 1.9、只使用username,后续运行提示输入密码 curl -u username http://www.test.com      2.1、参数 -o(小写)下载文件,下载到本地的文件需自己命名 curl -o img1.jpg http:www.test.com/img1.jpg 同时下载多个文件 curl -o img1.jpg http://www.test.com/img1.jpg -o img2.jpg http://www.test.com/img2.jpg 2.2、参数 -O(大写)以服务器上的名称保存文件到本地 curl -O http://www.test.com/img1.jpg 2.3、循环下载,下载部分文件。
阅读全文