Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 2, 2021 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/828be61e28de0dbeb4f1658ab9516dd8 to your computer and use it in GitHub Desktop.
Save parzibyte/828be61e28de0dbeb4f1658ab9516dd8 to your computer and use it in GitHub Desktop.
// Extraer lo que hay entre <body> y </body>
const char inicioEtiqueta[] = "<body>";
const char finEtiqueta[] = "</body>";
size_t longitudInicioEtiqueta = strlen(inicioEtiqueta);
char *punteroInicio = strstr(contenido, inicioEtiqueta) + longitudInicioEtiqueta;
char *punteroFin = strstr(contenido, finEtiqueta);
if (punteroInicio == NULL || punteroFin == NULL)
{
printf("No se encontraron las etiquetas");
return;
}
char cuerpoHtml[TAMANIO_MAXIMO_CONTENIDO] = "";
char contenidoLimpio[TAMANIO_MAXIMO_CONTENIDO] = "";
size_t longitud = punteroFin - punteroInicio;
// Copiar el contenido del cuerpo a cuerpoHtml
strncpy(cuerpoHtml, punteroInicio, longitud);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment