वेब पर कब्जा और परिवर्तित करने के लिए उपकरण

URL और HTML को DOCX में बदलें

रूबी एपीआई

HTML या वेबपृष्ठों को परिवर्तित करने की क्षमता जोड़ना intआपके आवेदन के लिए वर्ड दस्तावेज़ कभी भी आसान नहीं रहे हैं GrabzIt की रूबी एपीआई। हालांकि इससे पहले कि आप याद रखें कि कॉल करने के बाद url_to_docx, html_to_docx or file_to_docx तरीके save or save_to विधि को वास्तव में DOCX बनाने के लिए कहा जाना चाहिए।

मूल विकल्प

DOCX के रूप में वेबपृष्ठों को कैप्चर करना पूरे वेब पेज को परिवर्तित करता है intoa वर्ड डॉक्यूमेंट जिसमें कई पेज हो सकते हैं। वेब पेज को रूपांतरित करने के लिए केवल एक पैरामीटर की आवश्यकता होती है intoa वर्ड डॉक्यूमेंट या HTML को DOCX में बदलें जैसा कि नीचे दिए गए उदाहरणों में दिखाया गया है।

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

कस्टम पहचानकर्ता

आप एक कस्टम पहचानकर्ता को पास कर सकते हैं Docx नीचे दिखाए गए तरीके, यह मान तब आपके GrabzIt Ruby हैंडलर को वापस कर दिया जाता है। उदाहरण के लिए, यह कस्टम पहचानकर्ता एक डेटाबेस पहचानकर्ता हो सकता है, जो किसी विशेष डेटाबेस रिकॉर्ड के साथ DOCX दस्तावेज़ को जोड़ने की अनुमति देता है।

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::DOCXOptions.new()
options.customId = "123456"

grabzItClient.url_to_docx("https://www.tesla.com", options)
# Then call the save method
grabzItClient.save("http://www.example.com/handler/index")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::DOCXOptions.new()
options.customId = "123456"

grabzItClient.html_to_docx("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the save method
grabzItClient.save("http://www.example.com/handler/index")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::DOCXOptions.new()
options.customId = "123456"

grabzItClient.file_to_docx("example.html", options)
# Then call the save method
grabzItClient.save("http://www.example.com/handler/index")

शीर्षलेख और पाद लेख

किसी वर्ड डॉक्यूमेंट में हेडर या फूटर जोड़ने के लिए आप अनुरोध कर सकते हैं कि आप किसी विशेष को लागू करना चाहते हैं टेम्पलेट DOCX को जनरेट किया जा रहा है। यह टेम्पलेट होना चाहिए saveडी अग्रिम में और किसी विशेष चर के साथ हेडर और फुटर की सामग्री को निर्दिष्ट करेगा। उपयोगकर्ता के नीचे दिए गए उदाहरण कोड में वे "मेरे टेम्पलेट" नामक एक टेम्पलेट का उपयोग कर रहे हैं।

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::DOCXOptions.new()
options.templateId = "my template"

grabzItClient.url_to_docx("https://www.tesla.com", options)
# Then call the save or save_to method
grabzItClient.save_to("result.docx")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::DOCXOptions.new()
options.templateId = "my template"

grabzItClient.html_to_docx("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the save or save_to method
grabzItClient.save_to("result.docx")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::DOCXOptions.new()
options.templateId = "my template"

grabzItClient.file_to_docx("example.html", options)
# Then call the save or save_to method
grabzItClient.save_to("result.docx")

HTML तत्व को DOCX में बदलें

यदि आप किसी HTML एलिमेंट जैसे डिव या स्पैन को सीधे कन्वर्ट करना चाहते हैं intoa वर्ड डॉक्यूमेंट आप GrabzIt के रूबी जेम के साथ कर सकते हैं। आपको पास होना चाहिए सीएसएस चयनकर्ता जिस HTML एलिमेंट को आप कन्वर्ट करना चाहते हैं targetElement उसकि विधि DOCXOptions वर्ग.

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

इस उदाहरण में, हम उस अवधि की सभी सामग्री को कैप्चर करना चाहते हैं जिसके पास आईडी है Article, इसलिए हम इसे GrabzIt API से पास करते हैं जैसा कि नीचे दिखाया गया है।

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::DOCXOptions.new()
options.targetElement = "#Article"

grabzItClient.url_to_docx("http://www.bbc.co.uk/news", options)
# Then call the save or save_to method
grabzItClient.save_to("result.docx")