EXPRESIONES REGULARES(CURL)
Introducción
Curl es una herramienta para transferir datos entre servidores, protocolos de soporte, que incluyen:
- HTTP
- HTTPS
- FTP
- IMAP
- LDAP
- POP3
- SCP
- SFTP
- SMB
- SMTP
- etc…
Opciones
| Comando | Descripción |
|---|---|
-o <file> # –output: write to file |
curl enviar solicitud |
-u user:pass # –user: authentication |
curl enviar solicitud con detalles |
-v # –verbose: Make curl verbose during operation |
curl no mostrar indicador de progreso ni errores |
-vv # more verbose |
curl mostrar errores pero no indicador de progreso |
-s # –silent: don’t show progress meter or errors |
curl mostrar errores pero no indicador de progreso |
-S # –show-error: When used with –silent (-sS), show errors but no progress meter |
curl mostrar errores pero no indicador de progreso |
-i # –include: include HTTP headers in the output |
curl incluir encabezados HTTP en la salida |
-I # –head: header only |
curl solo mostrar encabezados |
Solicitar
-X POST# --request-L# If the page redirects, follow the link-F# --form: HTTP POST data for multipart/form-data
Datos
# --data: HTTP post data # URL encoding (eg, status="Hello")-d 'data'# --data pass file-d @file# --get: send -d data via get-G
Encabezado de información
-A <str># --user-agent-b name=val# --cookie-b FILE# --cookie-H "X-Foo: y"# --header--compressed# use deflate/gzip
SSL
--cacert <file>--capath <dir>
-E, --cert <cert># --cert: client certificate file--cert-type# der/pem/eng-k, --insecure# For self-signed certificates
Instalar
apk add --update curl # install in alpine linux
Ejemplo
| Comando | Descripción |
|---|---|
curl -I https://cheatsheets.zip |
curl envía una solicitud |
curl -v -I https://cheatsheets.zip |
curl solicitud con detalles |
curl -X GET https://cheatsheets.zip |
utilizar el método http explícito para curl |
curl --noproxy 127.0.0.1 http://www.stackoverflow.com |
curl sin proxy http |
curl --connect-timeout 10 -I -k https://cheatsheets.zip |
curl no tiene tiempo de espera por defecto |
curl --verbose --header "Host: www.mytest.com:8182" cheatsheets.zip |
curl obtener un encabezado extra |
curl -k -v https://www.google.com |
curl obtener respuesta con encabezados |
Carga de archivos múltiples
$ curl -v --include \
--form key1=value1 \
--form upload=@localfilename URL
Pretifique la salida de json para la respuesta de rizo
$ curl -XGET http://${elasticsearch_ip}:9200/_cluster/nodes | python -m json.tool
POST DE CURL
| Comando | Descripción |
|---|---|
curl -d "name=username&password=123456" <URL> |
curl enviar solicitud |
curl <URL> -H "content-type: application/json" -d "{ \"woof\": \"bark\"}" |
curl envía json |
CURL script install rvm
curl -sSL https://get.rvm.io | bash
CURL Advanced
| Comando | Descripción |
|---|---|
curl -L -s http://ipecho.net/plain, curl -L -s http://whatismijnip.nl |
consigue mi público IP |
curl -u $username:$password http://repo.dennyzhang.com/README.txt |
curl con credenciales |
curl -v -F key1=value1 -F upload=@localfilename <URL> |
curl subir |
curl -k -v --http2 https://www.google.com/ |
usar http2 curl |
curl -T cryptopp552.zip -u test:test ftp://10.32.99.187/ |
rizo ftp subir |
curl -u test:test ftp://10.32.99.187/cryptopp552.zip -o cryptopp552.zip |
rizo ftp descargar |
curl -v -u admin:admin123 --upload-file package1.zip http://mysever:8081/dir/package1.zip |
cargar con credenciales curl |
Verifique el tiempo de respuesta del sitio web
curl -s -w \
'\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nAppCon time:\t%{time_appconnect}\nRedirect time:\t%{time_redirect}\nPreXfer time:\t%{time_pretransfer }\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' \
-o /dev/null https://www.google.com
Use Curl para verificar si hay un recurso remoto disponible
curl -o /dev/null --silent -Iw "%{http_code}" https://example.com/my.remote.tarball.gz
Descarga del archivo
curl https://example.com | \
grep --only-matching 'src="[^"]*.[png]"' | \
cut -d \" -f2 | \
while read i; do curl https://example.com/"${i}" \
-o "${i##*/}"; done
Descargue todos los archivos PNG del sitio (usando GNU grep)
Descargue el archivo, guarde el archivo sin cambiar su nombre
curl --remote-name "https://example.com/linux-distro.iso"
Cambiar el nombre del archivo
curl --remote-name "http://example.com/index.html" --output foo.html
Continuar descarga parcial
curl --remote-name --continue-at -"https://example.com/linux-distro.iso"
Descargue archivos de múltiples dominios
curl "https://www.{example,w3,iana}.org/index.html" --output "file_#1.html"
Descargue una serie de archivos
curl "https://{foo,bar}.com/file_[1-4].webp" --output "#1_#2.webp"
Descargue una serie de archivos (output foo_file1.webp, foo_file2.webp… bar_file1.webp, etc.)
Redireccionar salida al archivo
$ curl http://url/file > file
Autenticación básica
$ curl --user username:password http://example.com/$ curl -u username:password http://example.com/
Escriba en el archivo en lugar de stdout
$ curl -o file http://url/file$ curl --output file http://url/file
Descargar información del encabezado
$ curl -I url
# display header information
Escriba la salida en un archivo llamado remote_file
$ curl -o file http://url/file$ curl --output file http://url/file
Ejecute la secuencia de comandos remota
$ curl -s http://url/myscript.sh
Archivo de configuración
curl -K file# read configuration from filecurl --config file$HOME/.curlrc# default configuration file on UNIX-like systems
