

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 獲取有關 Amazon Textract 文檔分析作業的數據，使用AWSSDK
<a name="example_textract_GetDocumentAnalysis_section"></a>

下列程式碼範例示範如何獲取 Amazon Textract 文件分析任務的相關資訊。

------
#### [ Python ]

**適用於 Python (Boto3) 的 SDK**  
  

```
class TextractWrapper:
    """Encapsulates Textract functions."""
    def __init__(self, textract_client, s3_resource, sqs_resource):
        """
        :param textract_client: A Boto3 Textract client.
        :param s3_resource: A Boto3 Amazon S3 resource.
        :param sqs_resource: A Boto3 Amazon SQS resource.
        """
        self.textract_client = textract_client
        self.s3_resource = s3_resource
        self.sqs_resource = sqs_resource

    def get_analysis_job(self, job_id):
        """
        Gets data for a previously started detection job that includes additional
        elements.

        :param job_id: The ID of the job to retrieve.
        :return: The job data, including a list of blocks that describe elements
                 detected in the image.
        """
        try:
            response = self.textract_client.get_document_analysis(
                JobId=job_id)
            job_status = response['JobStatus']
            logger.info("Job %s status is %s.", job_id, job_status)
        except ClientError:
            logger.exception("Couldn't get data for job %s.", job_id)
            raise
        else:
            return response
```
+  在 [GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/textract#code-examples)，尋找指示和更多代碼。
+  如需 API 詳細資訊，請參[GetDocumentAnalysis](https://docs.aws.amazon.com/goto/boto3/textract-2018-06-27/GetDocumentAnalysis)在*AWSSDK for Python (Boto3) API 參考*。

------

如需完整的清單AWSSDK 開發人員指南和代碼示例，請參閲[將 Amazon Textract 與AWSSDK](sdk-general-information-section.md)。本主題還包括有關入門信息和以前 SDK 版本的詳細信息。