12.2 清理bug修改

This commit is contained in:
zy123 2024-12-03 09:07:14 +08:00
parent ce5a7898d7
commit d161965f5d
2 changed files with 21 additions and 4 deletions

View File

@ -72,6 +72,7 @@ def convert_pdf_to_markdown(file_path):
if __name__ == "__main__":
file_path=r"C:\Users\Administrator\Desktop\fsdownload\e702f1e6-095d-443d-bb7d-ef2e42037cb1\ztbfile_procurement.pdf"
# file_path=r"C:\Users\Administrator\Desktop\fsdownload\e702f1e6-095d-443d-bb7d-ef2e42037cb1\ztbfile_procurement.pdf"
file_path=r"C:\Users\Administrator\Desktop\货物标\output1\招标文件实高电子显示屏_procurement.pdf"
res=convert_pdf_to_markdown(file_path)
print(res)

View File

@ -111,9 +111,25 @@ def main():
if status_info.status.lower() == 'success':
print("Job completed successfully.")
# Step 3: Retrieve the parsing result
result = docmind_client.get_result(job_id)
print("Parsing Result:")
print(result)
try:
result = docmind_client.get_result(job_id)
except Exception as e:
print(f"获取结果失败: {e}")
return
# 提取并连接每个布局的 'markdownContent'
try:
layouts = result.get('layouts', [])
markdown_contents = [layout.get('markdownContent', '') for layout in layouts]
concatenated_markdown = '\n'.join(markdown_contents)
# 将连接后的 markdown 写入 'extract.txt'
with open('extract.txt', 'w', encoding='utf-8') as extract_file:
extract_file.write(concatenated_markdown)
print("Markdown 内容已成功提取到 'extract.txt'")
except Exception as e:
print(f"处理并写入 Markdown 内容失败: {e}")
else:
print("Job failed. Please check the error logs for more details.")