반응형
from azure.core.credentials import AzureKeyCredential
from azure.ai.formrecognizer import DocumentAnalysisClient
from azure.storage.blob import ContainerClient
endpoint = "FORM_RECOGNIZER_END_POINT"
key = "FORM_RECOGNIZER_KEY"
def get_blob_url():
STORAGE_CONSTR = "BLOB_STORAGE_CONNECTION_STRING"
SOURCE_NAME = "BLOB_STORAGE_CONTAINER_NAME"
FILE_NAME = "sample.pdf"
container = ContainerClient.from_connection_string(
conn_str=STORAGE_CONSTR,
container_name=SOURCE_NAME
)
blob_list = container.list_blobs()
blob_url = container.url
for blob in blob_list:
if blob.name == FILE_NAME:
formUrl = blob_url+"/"+blob.name
print(formUrl)
return formUrl
def analyze_read():
formUrl = get_blob_url()
print("========= Process start ==========\\n")
document_analysis_client = DocumentAnalysisClient(
endpoint=endpoint, credential=AzureKeyCredential(key)
)
poller = document_analysis_client.begin_analyze_document_from_url("prebuilt-read", formUrl)
result = poller.result()
print("Document contains content: ", result.content)
print("========= Process end ==========\\n")
if __name__ == "__main__":
analyze_read()
반응형
'Azure' 카테고리의 다른 글
Form Recognizer의 학습된 Custom model을 기준으로 Azure Blob Storage의 pdf 파일 Python으로 분석하기 (0) | 2023.06.30 |
---|---|
Form Recognizer의 Custom model을 python을 이용해 가져오기 (0) | 2023.06.29 |
Azure Cognitive Service의 Form Recognizer 사용해 보기 (0) | 2023.06.23 |
Power Apps와 Power Automate를 이용해 Azure Blob Storage의 PDF파일 Viewer로 보여주기 (1) | 2022.09.29 |
Power Apps를 이용해 Upload Template 설정하기 (0) | 2022.09.29 |