数据抓取使用:
Library: requests urlib pycurl
tools: curl wget httpie
curl使用
shell
curl http://www.baidu.com
-A 设置user-agent
curl -A ‘Chrome’ https://www.baidu.com
-X 设置请求方式
curl -X POST http://httpbin.org/post
-I只返回请求的头信息
curl -I http://httpbin.org/get
-d以POST请求方式请求URL,并发送相应的参数
curl -d test=123 http://httpbin.org/post
curl -d “a=1&b=2&c=3” http://httpbin.org/post
curl -d a=1 -d b=2 http://httpbin.org/post
curl -d @filename http://httpbin.org/post
-O 下载文件并以远程的文件名保存到本地
curl -O http://httpbin.org/image/jpeg
-o 重命名
curl -o fox.jpeg http://httpbin.org/image/jpeg
-L跟随重定向请求
curl -L https://baidu.com
-H设置头信息
curl -o image.webp -H “accept:image/webp” http://httpbin.org/image
curl -o image.png -H “accept:image/png” http://httpbin.org/image
-k允许发起不安全请求
-b 设置cookies
curl -b a=test http://httpbin.org/cookies
-s不显示其他无关信息
curl --help查看更多参数
man curl更详细 q退出
curl http://httpbin.org/get|grep -E “\d+” |grep -v User-Agent
-E表示正则匹配 d数字 -v不包含
wget专注于下载