Tabla de Contenidos

cURL

Herramienta de transferencia de datos mediante URL. Soporta DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET y TFTP

Ejemplos

Salida silenciosa

Si no queremos que muestre información durante la ejecución, solo el recurso que le hayamos pedido:

curl -s https://example.org

Test de velocidad

curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -

Seguir redirección

Si alguna web nos devuelve un código 302, quiere decir que el documento solicitado se ha movido a una nueva ubicación. Por ejemplo:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://example.org/doc2">here</a>.</p>
<hr>
<address>Apache/2.2.3 (Red Hat) Server at example.org Port 80</address>
</body></html>

Si queremos decirle a cURL que cuando se encuentre en esta situación, sigua esa redirección, la pasamos la opción -L:

curl -L https://www.example.org/doc1