Web Yakalama ve Dönüştürme Araçları

URL’leri ve HTML’yi DOCX’e dönüştürme

Node.js API

HTML veya web sayfalarını dönüştürme yeteneği ekleme into Uygulamanıza yönelik Word belgeleri hiç bu kadar kolay olmamıştı GrabzIt'ın Node.js API'si. Ancak başlamadan önce aradıktan sonra bunu hatırlayın. url_to_docx, html_to_docx or file_to_docx yöntemler save or save_to DOCX'i oluşturmak için yöntem çağrılmalıdır.

Temel Seçenekler

Web sayfalarını DOCX olarak yakalamak, tüm web sayfasını dönüştürür into Çok sayıda sayfadan oluşan bir Word belgesi. Bir web sayfasını dönüştürmek için sadece bir parametre gereklidir into bir Word belgesi veya HTML'yi DOCX'e dönüştür aşağıdaki örneklerde gösterildiği gibi.

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

Özel tanımlayıcı

Özel bir tanımlayıcıyı DOCX Aşağıda gösterildiği gibi yöntemler, bu değer daha sonra GrabzIt Node.js işleyicinize döndürülür. Örneğin, bu özel tanımlayıcı, bir DOCX belgesinin belirli bir veritabanı kaydı ile ilişkilendirilmesine izin veren bir veritabanı tanımlayıcısı olabilir.

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;
    }
});

Başlıkları ve Altbilgiler

Bir Word belgesine üstbilgi veya altbilgi eklemek için, belirli bir dilekçe uygulamak isteyebilirsiniz. şablon üretilen DOCX'e. Bu şablon olmalı saved önceden ve herhangi bir özel değişkenle birlikte üstbilgi ve altbilgi içeriğini belirtir. Aşağıdaki örnek kodda, kullanıcı "benim şablonum" adı verilen bir şablon kullanıyor.

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;
    }
});

HTML öğesini DOCX'e dönüştür

Doğrudan bir div veya span gibi bir HTML öğesini doğrudan dönüştürmek istiyorsanız intGrabzIt'ın Node.js kütüphanesiyle yapabilirsiniz. Geçmelisin CSS seçici dönüştürmek istediğiniz HTML öğesinin setTargetElement parametre.

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

Bu örnekte, yayındaki kimliği olan yayılma alanındaki tüm içeriği yakalamak istiyoruz. Articlebu nedenle bunu aşağıda gösterildiği gibi GrabzIt API'sine aktarıyoruz.

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;
    }
});