כלים ללכידה ולהמרה של האינטרנט

המרת כתובות URL ו- HTML ל- DOCX

ממשק ה- API של Node.js

הוספת היכולת להמיר HTML או דפי אינטרנט into מסמכי Word ליישום שלך מעולם לא היו קלים יותר ממשק ה- API של GrabzIt Node.js. עם זאת לפני שתתחיל לזכור את זה לאחר התקשרות אל url_to_docx, html_to_docx or file_to_docx שיטות save or save_to יש לקרוא לשיטה ליצירת DOCX בפועל.

אפשרויות בסיסיות

לכידת דפי אינטרנט כאשר DOCX ממיר את כל דף האינטרנט intoa מסמך Word שיכול להכיל עמודים רבים. כדי להמיר דף אינטרנט נדרש פרמטר אחד בלבד intמסמך Word או ל- המרת HTML ל- DOCX כפי שמוצג בדוגמאות שלהלן.

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

מזהה מותאם אישית

אתה יכול להעביר מזהה מותאם אישית אל ה- DOCX שיטות כמוצג להלן, ערך זה יוחזר למטפל GrabzIt Node.js שלך. לדוגמה, מזהה מותאם אישית זה יכול להיות מזהה בסיס נתונים, המאפשר לשייך מסמך DOCX לרשומת מסד נתונים מסוימת.

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

כותרות עליונות ותחתונות

כדי להוסיף כותרת עליונה או כותרת תחתונה למסמך Word אתה יכול לבקש שתרצה להחיל מסוים תבנית ל- DOCX שנוצר. תבנית זו חייבת להיות saved מראש ופרט את תוכן הכותרת העליונה התחתונה יחד עם כל משתנים מיוחדים. בקוד הדוגמה למטה המשתמש משתמש בתבנית שהם יצרו בשם "התבנית שלי".

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 ל- DOCX

אם ברצונך להמיר אלמנט HTML כגון div או span ישירות intoa מסמך Word שאתה יכול עם ספריית Node.js של GrabzIt. עליך לעבור את בורר CSS של אלמנט ה- HTML שברצונך להמיר ל- setTargetElement פָּרָמֶטֶר.

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

בדוגמה זו ברצוננו ללכוד את כל התוכן בטווח שיש לו מזהה Articleלכן אנו מעבירים זאת ל- API של GrabzIt כמוצג להלן.

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