Nuna daftarin aiki a cikin gidan yanar gizo bayan canza Kalma zuwa HTML ta amfani da Python SDK
Wannan labarin zai bayyana matakan canza Kalma zuwa HTML ta amfani da Python SDK. Mun san cewa ana amfani da takaddun Kalma don raba bayanan hukuma da na sirri. Koyaya, ƙalubalen yana zuwa lokacin da muke buƙatar duba ko nuna daftarin aiki a cikin mai binciken gidan yanar gizo. Don haka mafita mai wayo shine canza takaddun Word zuwa tsarin HTML.
- API ɗin Canjawar Kalma zuwa HTML
- Maida Kalma zuwa HTML ta amfani da Python
- Canza Kalma zuwa HTML ta amfani da Umurnin CURL
API ɗin Canjawar Kalma zuwa HTML
Aspose.Words Cloud yana da ikon loda takaddun MS Word, OpenOffice, ko WordProcessingML. Yana ba ku damar sarrafa su a matakin kashi ɗaya ko canza waɗannan fayilolin zuwa Tsarin Fayil ɗin Tallafi. Yanzu don amfani da fasalolin sarrafa takardu a cikin aikace-aikacen Python, muna buƙatar amfani da Aspose.Words Cloud SDK don Python. Don haka don amfani da SDK, matakin farko shine shigarwa wanda ke akwai don saukewa a PIP da GitHub. Yi umarni mai zuwa akan tashar layin umarni don shigar da SDK:
pip install aspose-words-cloud
Mataki na gaba shine ƙirƙirar asusun kyauta ta ziyartar Aspose.Cloud dashboard, ta yadda zaku iya sarrafa takaddun ku a cikin ma’ajiyar girgije.
Maida Kalma zuwa HTML ta amfani da Python
Da fatan za a bi umarnin da aka bayar a ƙasa don loda daftarin aiki daga faifan gida kuma loda shi zuwa ma’ajiyar gajimare. Sa’an nan kuma za mu fara aikin yau da kullum don canza fayil ɗin DOC zuwa tsarin HTML kuma mu adana fitarwa a cikin ajiyar girgije iri ɗaya.
- Da farko, ƙirƙiri misali na WordsApi ta amfani da takaddun shaidar abokin ciniki
- Na biyu, daftarin kalma daga faifan gida da loda zuwa ma’ajiyar girgije ta amfani da hanyar uploadfile(…).
- Yanzu ƙirƙiri misali na GetDocumentWithFormatRequest yana ma’anar shigar da fayil ɗin Kalma da takaddar HTML
- A ƙarshe, kira hanyar samundocumentwithformat(…) don fara aiwatar da juyawa
# Don ƙarin samfurori, da fatan za a ziyarci https://github.com/aspose-words-cloud/aspose-words-cloud-python
# Samu App Key da App SID daga https://dashboard.aspose.cloud/
try:
# Shaidar abokin ciniki
client_secret = "1c9379bb7d701c26cc87e741a29987bb"
client_id = "bbf94a2c-6d7e-4020-b4d2-b9809741374e"
# ƙirƙirar misali na WordsApi
words_api = WordsApi(client_id,client_secret)
# Sunan takardar shigar da kalmar
inputFileName = 'test_multi_pages.docx'
resultantFile = 'Converted.html'
# Loda tushen daftarin aiki na Kalma zuwa Cloud Storage
words_api.upload_file(asposewordscloud.models.requests.UploadFileRequest(open('C:\\Users\\Downloads\\'+inputFileName, 'rb'), "", None))
# Ƙirƙiri abu don jujjuya daftarin aiki
request = asposewordscloud.models.requests.GetDocumentWithFormatRequest(inputFileName, "HTML", None, None, None,
None, resultantFile, None)
# fara Kalma zuwa JPEG aikin jujjuyawar
result = words_api.get_document_with_format(request)
# buga saƙo a cikin na'ura mai kwakwalwa (na zaɓi)
print('Conversion process completed successfully !')
except ApiException as e:
print("Exception while calling WordsApi: {0}".format(e))
Za a iya sauke daftarin kalma samfurin da aka yi amfani da shi a cikin misalin da ke sama daga testmultipages.docx.
Canza Kalma zuwa HTML ta amfani da Umurnin CURL
Hakanan za’a iya amfani da umarnin CURL don canza takaddun kalmomi zuwa tsarin HTML. Duk da haka kafin mu fara aiwatar da juyi, muna buƙatar ƙirƙirar alamar samun damar JWT dangane da bayanan abokin ciniki na sirri. Don haka don Allah ƙirƙirar alamar JWT ta aiwatar da umarni mai zuwa.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Da zarar an ƙirƙiri alamar JWT, muna buƙatar aiwatar da umarni mai zuwa don loda daftarin samfurin kalma zuwa ma’ajiyar girgije:
curl -v -X PUT "https://api.aspose.cloud/v4.0/words/storage/file/input.docx" \
-H "accept: application/json" \
-H "Authorization: Bearer <JWT Token>" \
-H "Content-Type: multipart/form-data" \
-d {"fileContent":{c:\Users\nayyer\Downloads\test_doc.docx}}
Yanzu da fatan za a aiwatar da umarni mai zuwa don canza takaddar kalmar daga ma’ajin gajimare zuwa tsarin HTML kuma adana sakamakon HTML zuwa ma’ajiyar girgije iri ɗaya.
curl -v -X GET "https://api.aspose.cloud/v4.0/words/test_multi_pages.docx?format=HTML&outPath=Resultant.html" \
-H "accept: application/octet-stream" \
-H "Authorization: Bearer <JWT Token>"
Kammalawa
A cikin wannan labarin, mun koyi game da matakan aiwatar da Kalma zuwa HTML ta amfani da Python SDK. Hakazalika, mun kuma bincika zaɓi don yin DOC zuwa HTML, DOCX zuwa canza HTML ta amfani da umarnin cURL. Cikakken tsarin jujjuyawar yana da sauƙi kuma mai sauƙi wanda kawai kuna buƙatar mayar da hankali kan buƙatun kasuwancin ku kuma ku manta game da rikitattun juzu’in daftarin aiki. API ɗin yana sarrafa duk tsarin juzu’i na tsaka-tsaki kuma yana dawo da abun ciki na sakamako. Muna ba da shawarar ku bincika Jagorancin Masu Shirye-shiryen don koyo game da sauran damar da SDK ke bayarwa. Bugu da ƙari, cikakken lambar tushen girgije SDK yana samuwa don saukewa akan GitHub kuma kuna iya saukewa da sabunta shi gwargwadon bukatunku.
Maudu’ai masu dangantaka
Muna ba ku shawarar ku ziyarci labarai masu zuwa don koyo game da su: