Herramientas para capturar y convertir la web

Convierta URL y HTML a DOCX

API Node.js

Agregar la capacidad de convertir HTML o páginas web into Los documentos de Word para su aplicación nunca han sido tan fáciles con GrabzIt's Node.js API. Sin embargo, antes de comenzar, recuerde que después de llamar al url_to_docx, html_to_docx or file_to_docx métodos de save or save_to Se debe llamar al método para crear realmente el DOCX.

Opciones basicas

La captura de páginas web a medida que DOCX convierte la página web completa into un documento de Word que puede constar de muchas páginas. Solo se requiere un parámetro para convertir una página web into un documento de Word o para convertir HTML a DOCX como se muestra en los ejemplos a continuación.

client.url_to_docx("https://www.tesla.com");
//Then call the save or save_to method
client.html_to_docx("<html><body><h1>Hello World!</h1></body></html>");
//Then call the save or save_to method
client.file_to_docx("example.html");
//Then call the save or save_to method

Identificador personalizado

Puede pasar un identificador personalizado a DOCX métodos como se muestra a continuación, este valor se devuelve a su controlador GrabzIt Node.js. Por ejemplo, este identificador personalizado podría ser un identificador de base de datos, permitiendo que un documento DOCX se asocie con un registro de base de datos particular.

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"customId":123456};

client.url_to_docx("https://www.tesla.com", options);
//Then call the save method
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"customId":123456};

client.html_to_docx("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the save method
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"customId":123456};

client.file_to_docx("example.html", options);
//Then call the save method
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});

Encabezados y pies de página

Para agregar un encabezado o pie de página a un documento de Word, puede solicitar que desee aplicar un determinado plantilla al DOCX que se genera. Esta plantilla debe ser saved de antemano y especificará el contenido del encabezado y pie de página junto con cualquier variable especial. En el código de ejemplo a continuación, el usuario está usando una plantilla que creó llamada "mi plantilla".

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"templateId":"my template"};

client.url_to_docx("https://www.tesla.com", options);
//Then call the save or save_to method
client.save_to("result.docx", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"templateId":"my template"};

client.html_to_docx("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the save or save_to method
client.save_to("result.docx", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"templateId":"my template"};

client.file_to_docx("example.html", options);
//Then call the save or save_to method
client.save_to("result.docx", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});

Convertir elemento HTML a DOCX

Si solo desea convertir un elemento HTML como un div o span directamente into un documento de Word que pueda con la biblioteca GrabzIt's Node.js. Debes pasar el Selector de CSS del elemento HTML que desea convertir a setTargetElement parámetro.

...
<span id="Article">
<p>This is the content I am interested in.</p>
<img src="myimage.jpg">
</span>
...

En este ejemplo, deseamos capturar todo el contenido en el lapso que tiene la identificación de Article, por lo tanto, pasamos esto a GrabzIt API como se muestra a continuación.

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

client.url_to_docx("http://www.bbc.co.uk/news", {"targetElement": "#Article"});
//Then call the save or save_to method
client.save_to("result.docx", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});