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

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

पायथन एपीआई

HTML या वेबपृष्ठों को परिवर्तित करने की क्षमता जोड़ना intआपके आवेदन के लिए वर्ड दस्तावेज़ कभी भी आसान नहीं रहे हैं GrabzIt के पायथन एपीआई। हालांकि इससे पहले कि आप याद रखें कि कॉल करने के बाद URLToDOCX, HTMLToDOCX or FileToDOCX तरीके Save or SaveTo विधि को वास्तव में DOCX बनाने के लिए कहा जाना चाहिए।

मूल विकल्प

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

grabzIt.URLToDOCX("https://www.tesla.com")
# Then call the Save or SaveTo method
grabzIt.HTMLToDOCX("<html><body><h1>Hello World!</h1></body></html>")
# Then call the Save or SaveTo method
grabzIt.FileToDOCX("example.html")
# Then call the Save or SaveTo method

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

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

from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.customId = "123456"

grabzIt.URLToDOCX("https://www.tesla.com", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")
from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.customId = "123456"

grabzIt.HTMLToDOCX("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")
from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.customId = "123456"

grabzIt.FileToDOCX("example.html", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")

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

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

from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.templateId = "my template"

grabzIt.URLToDOCX("https://www.tesla.com", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.docx")
from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.templateId = "my template"

grabzIt.HTMLToDOCX("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.docx")
from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.templateId = "my template"

grabzIt.FileToDOCX("example.html", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.docx")

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

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

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

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

from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.targetElement = "#Article"

grabzIt.URLToDOCX("http://www.bbc.co.uk/news", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.docx")